From 4ae1d74e334b27de623dbbd2be5c82393870bccb Mon Sep 17 00:00:00 2001 From: hillerliao Date: Tue, 26 Apr 2022 23:36:26 +0800 Subject: [PATCH] add pgyer --- rsshub/blueprints/main.py | 4 ++++ rsshub/spiders/pgyer/app.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 rsshub/spiders/pgyer/app.py diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 3e8a2d2..8d8cb74 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -195,6 +195,10 @@ def producthunt_search(keyword='', period=''): from rsshub.spiders.producthunt.search import ctx return render_template('main/atom.xml', **filter_content(ctx(keyword,period))) +@bp.route('/pgyer/') +def pgyer_app(category=''): + from rsshub.spiders.pgyer.app import ctx + return render_template('main/atom.xml', **filter_content(ctx(category))) @bp.route('/mp/gh/') def mp_gh(gh=''): diff --git a/rsshub/spiders/pgyer/app.py b/rsshub/spiders/pgyer/app.py new file mode 100644 index 0000000..a6f2005 --- /dev/null +++ b/rsshub/spiders/pgyer/app.py @@ -0,0 +1,28 @@ +from rsshub.utils import DEFAULT_HEADERS +from rsshub.utils import fetch + +domain = 'https://www.pgyer.com' + +def ctx(category=''): + url = f"{domain}/{category}" + tree = fetch(url,headers=DEFAULT_HEADERS) + posts = tree.css('.container.content.pt-10') + posts = tree.css('html') + title = tree.xpath('//meta[@property="og:description"]').attrib['content'] + app_name = tree.css('title::text').get() + return { + 'title': f'{title} - 蒲公英', + 'link': url, + 'description': f'{app_name} 安装包更新 - 蒲公英', + 'author': 'hillerliao', + 'items': list(map(parse, posts)) + } + +def parse(post): + item = {} + item['title'] = post.xpath('//meta[@property="og:description"]').attrib['content'] + item['description'] = item['title'] + ';' \ + + post.css('ul.breadcrumb > li::text').getall()[1] + ';' \ + + post.css('ul.breadcrumb > li::text').getall()[2] + item['link'] = post.css('img.qrcode').attrib['src'] + return item \ No newline at end of file