From 6620af70bbb8b4d549fca2d6feb81992e0eea7fd Mon Sep 17 00:00:00 2001 From: hillerliao Date: Sun, 12 Apr 2020 12:52:34 +0800 Subject: [PATCH] format weiyangx.express by flake8 --- rsshub/blueprints/main.py | 5 +++++ rsshub/spiders/techcrunch/tag.py | 1 - rsshub/spiders/weiyangx/express.py | 36 ++++++++++++++++++++++++++++++ rsshub/templates/main/feeds.html | 12 ++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 rsshub/spiders/weiyangx/express.py diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 29eb4b3..1817575 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -120,3 +120,8 @@ def chaindd_column(category=''): def techcrunch_tag(category=''): from rsshub.spiders.techcrunch.tag import ctx return render_template('main/atom.xml', **filter_content(ctx(category))) + +@bp.route('/weiyangx/express/') +def weiyangx_express(): + from rsshub.spiders.weiyangx.express import ctx + return render_template('main/atom.xml', **filter_content(ctx())) diff --git a/rsshub/spiders/techcrunch/tag.py b/rsshub/spiders/techcrunch/tag.py index 4ad8742..defc844 100644 --- a/rsshub/spiders/techcrunch/tag.py +++ b/rsshub/spiders/techcrunch/tag.py @@ -17,7 +17,6 @@ def ctx(category=''): res = requests.get(url, headers=DEFAULT_HEADERS) res = json.loads(res.text) posts = res - print(posts) items = list(map(parse, posts)) return { 'title': f'{category} - tag - Techcrunch', diff --git a/rsshub/spiders/weiyangx/express.py b/rsshub/spiders/weiyangx/express.py new file mode 100644 index 0000000..929655a --- /dev/null +++ b/rsshub/spiders/weiyangx/express.py @@ -0,0 +1,36 @@ +import requests +import json +from rsshub.utils import DEFAULT_HEADERS + +domain = 'https://www.weiyangx.com' + + +def parse(post): + item = {} + item['title'] = post['post_title'] + item['description'] = post['post_content'] + post_id = post['post_id'] + item['link'] = f'{domain}/{post_id}.html' + item['pubDate'] = post['post_date'][0] + '-' + \ + post['post_date'][1] + '-' + \ + post['post_date'][2] + return item + + +def ctx(): + url = f'https://www.weiyangx.com/wp-admin/admin-ajax.php' + q_data = {"action": "load_more_express", + "offset": "00", + "category": "29817", + "_ajax_nonce": "235111d38c"} + + res = requests.post(url, data=q_data, headers=DEFAULT_HEADERS) + posts = json.loads(res.text)['expressList'] + items = list(map(parse, posts)) + return { + 'title': f'快讯 - 未央网', + 'description': f'快讯 - 未央网', + 'link': f'{domain}/category/express', + 'author': f'hillerliao', + 'items': items + } diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index 012f34e..215c794 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -203,4 +203,16 @@
+ +
+
+

未央网-国际快讯

+
未央网-国际快讯 by hillerliao
+

举例:https://rsshub-python.herokuapp.com/weiyangx/express/

+

路由:/weiyangx/express/

+
+
+
+ + {% endblock content %} \ No newline at end of file