From becc97a49a272ef05e111c88dbe3aefd2807fb24 Mon Sep 17 00:00:00 2001 From: hillerliao Date: Sat, 21 Aug 2021 10:02:44 +0800 Subject: [PATCH] add cls telegraph --- rsshub/blueprints/main.py | 7 ++++++- rsshub/spiders/cls/telegraph.py | 25 +++++++++++++++++++++++++ rsshub/templates/main/feeds.html | 12 ++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 rsshub/spiders/cls/telegraph.py diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 59487ba..37ac439 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -118,7 +118,12 @@ def xuangubao_xuangubao(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))) + return render_template('main/atom.xml', **filter_content(ctx(category))) + +@bp.route('/cls/telegraph/') +def cls_telegraph(): + from rsshub.spiders.cls.telegraph import ctx + return render_template('main/atom.xml', **filter_content(ctx())) @bp.route('/chaindd/column/') def chaindd_column(category=''): diff --git a/rsshub/spiders/cls/telegraph.py b/rsshub/spiders/cls/telegraph.py new file mode 100644 index 0000000..ae1f5a6 --- /dev/null +++ b/rsshub/spiders/cls/telegraph.py @@ -0,0 +1,25 @@ +import requests +from rsshub.utils import DEFAULT_HEADERS + + +def parse(post): + item = {} + item['title'] = post['title'] if post['title'] != '' else post['content'] + item['description'] = post['content'] + item['link'] = post['shareurl'] + item['pubDate'] = post['ctime'] + return item + + +def ctx(): + url = f'https://www.cls.cn/nodeapi/telegraphList' + res = requests.get(url, headers=DEFAULT_HEADERS) + posts = res.json()['data']['roll_data'] + items = list(map(parse, posts)) + return { + 'title': f'电报 - 财联社', + 'link': f'https://www.cls.cn/telegraph', + 'description': f'财联社电报', + 'author': 'hillerliao', + 'items': items + } diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index 2ca3fbd..08c1bec 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -181,6 +181,18 @@
+ +
+
+

财联社电报

+
财联社电报 by hillerliao
+

举例:https://pyrsshub.herokuapp.com/cls/telegraph

+

路由:/cls/telegraph

+
+
+
+ +