From a0bfac9f3e71460ad235db534052a02321dde6ff Mon Sep 17 00:00:00 2001 From: hillerliao Date: Sun, 12 Apr 2020 14:50:43 +0800 Subject: [PATCH] add weiyangx article in tag --- rsshub/blueprints/main.py | 5 +++++ rsshub/spiders/weiyangx/tag.py | 33 ++++++++++++++++++++++++++++++++ rsshub/templates/main/feeds.html | 13 +++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 rsshub/spiders/weiyangx/tag.py diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 1817575..0c0e338 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -125,3 +125,8 @@ def techcrunch_tag(category=''): def weiyangx_express(): from rsshub.spiders.weiyangx.express import ctx return render_template('main/atom.xml', **filter_content(ctx())) + +@bp.route('/weiyangx/tag/') +def weiyangx_tag(category=''): + from rsshub.spiders.weiyangx.tag import ctx + return render_template('main/atom.xml', **filter_content(ctx(category))) \ No newline at end of file diff --git a/rsshub/spiders/weiyangx/tag.py b/rsshub/spiders/weiyangx/tag.py new file mode 100644 index 0000000..7dc9373 --- /dev/null +++ b/rsshub/spiders/weiyangx/tag.py @@ -0,0 +1,33 @@ +import requests +import json +from rsshub.utils import DEFAULT_HEADERS + +domain = 'https://www.weiyangx.com' + + +def parse(post): + item = {} + item['title'] = post['title'] + item['description'] = post['content'] + item['link'] = post['url'] + item['author'] = post['authorMeta'] + return item + + +def ctx(category=''): + url = f'https://www.weiyangx.com/wp-admin/admin-ajax.php' + q_data = {"action": "home_load_more_news", + "postOffset": "00", + "tagId": category, + "_ajax_nonce": "1846edad4e"} + + res = requests.post(url, data=q_data, headers=DEFAULT_HEADERS) + posts = json.loads(res.text)['data'] + 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 215c794..61d43c9 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -215,4 +215,17 @@
+ +
+
+

未央网 tag文章列表

+
未央网 tag文章列表 by hillerliao
+

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

+

路由:/weiyangx/tag/:category

+

参数:category [必填,见 weiyangx 官网]

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