From 3e5345fc1548c81448f033f2affbaf563b6728d1 Mon Sep 17 00:00:00 2001 From: hillerliao Date: Wed, 25 Mar 2020 12:47:40 +0800 Subject: [PATCH] cailianshe press subject --- rsshub/blueprints/main.py | 7 ++++++- rsshub/spiders/cls/subject.py | 29 +++++++++++++++++++++++++++++ rsshub/templates/main/feeds.html | 13 +++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 rsshub/spiders/cls/subject.py diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 0292397..fc640f2 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -104,4 +104,9 @@ def eastmoney_report(category='', type=''): @bp.route('/xuangubao//') def xuangubao_xuangubao(type='', category=''): from rsshub.spiders.xuangubao.xuangubao import ctx - return render_template('main/atom.xml', **filter_content(ctx(type, category))) \ No newline at end of file + return render_template('main/atom.xml', **filter_content(ctx(type, category))) + +@bp.route('/cls/subject/') +def cls_subject(category=''): + from rsshub.spiders.cls.subject import ctx + return render_template('main/atom.xml', **filter_content(ctx(category))) \ No newline at end of file diff --git a/rsshub/spiders/cls/subject.py b/rsshub/spiders/cls/subject.py new file mode 100644 index 0000000..b12b05b --- /dev/null +++ b/rsshub/spiders/cls/subject.py @@ -0,0 +1,29 @@ +import requests +import json +from rsshub.utils import DEFAULT_HEADERS + + +def parse(post): + item = {} + item['title'] = post['ArticleTitle'] + item['description'] = post['ArticleBrief'] + articleid = post['ArticleId'] + item['link'] = f'https://api3.cls.cn/share/article/{articleid}?os=android&sv=734&app=' + item['author'] = post['ArticleAuthor'] + item['pubDate'] = post['ArticleTime'] + return item + + +def ctx(category=''): + url = f'https://i.cls.cn/articles/subject/v1/{category}?sign=ab07b305da92f72ea5e509ba6d1216ff&app=cailianpress&LastTime=&PageNum=20&os=android&sv=734' + res = requests.get(url, headers=DEFAULT_HEADERS) + res = json.loads(res.text) + posts = res + items = list(map(parse, posts)) + return { + 'title': f'{category} - 主题 - 财联社', + 'link': f'https://api3.cls.cn/share/subject/{category}?os=android&sv=734', + 'description': f'{category} - 主题 - 财联社', + 'author': 'hillerliao', + 'items': items + } diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index 4a8273d..f80dc50 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -163,4 +163,17 @@
+ + +
+
+

财联社主题动态

+
财联社主题动态 by hillerliao
+

举例:https://rsshub-python.herokuapp.com/cls/subject/1345

+

路由:/cls/subject/:category

+

参数:category [必填,见财联社APP主题栏目]

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