From 468ba996e78c96d50c2a2cb367d7aa9900060660 Mon Sep 17 00:00:00 2001 From: hillerliao Date: Sun, 8 Mar 2020 14:01:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A2=E6=96=B0=E7=BD=91=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=96=B0=E9=97=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsshub/blueprints/main.py | 7 ++++++- rsshub/spiders/caixin/scroll.py | 25 +++++++++++++++++++++++++ rsshub/templates/main/feeds.html | 13 +++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 rsshub/spiders/caixin/scroll.py diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 46da12f..c4513a5 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -89,4 +89,9 @@ def jiemian_newsflash(category=''): @bp.route('/csrc/audit/') def csrc_audit(category=''): from rsshub.spiders.csrc.audit import ctx - return render_template('main/atom.xml', **filter_content(ctx(category))) \ No newline at end of file + return render_template('main/atom.xml', **filter_content(ctx(category))) + +@bp.route('/caixin/scroll/') +def caixin_scroll(category=''): + from rsshub.spiders.caixin.scroll import ctx + return render_template('main/atom.xml', **filter_content(ctx(category))) \ No newline at end of file diff --git a/rsshub/spiders/caixin/scroll.py b/rsshub/spiders/caixin/scroll.py new file mode 100644 index 0000000..c989f06 --- /dev/null +++ b/rsshub/spiders/caixin/scroll.py @@ -0,0 +1,25 @@ +from rsshub.utils import fetch + +domain = 'http://www.caixin.com' + + +def parse(post): + item = {} + item['title'] = post.css('a::text').extract_first() + item['description'] = post.css('p::text').extract_first() + item['link'] = post.css('a::attr(href)').extract_first() + item['pubDate'] = post.css('span::text').extract_first() + return item + + +def ctx(category=''): + tree = fetch(f"{domain}/search/scroll/{category}.jsp") + posts = tree.css('dl') + channel_title = tree.css('b').css('b::text').extract_first() + return { + 'title': channel_title, + 'link': f'{domain}/search/scroll/{category}.jsp', + 'description': '财新网滚动新闻', + 'author': 'hillerliao', + 'items': list(map(parse, posts)) + } \ No newline at end of file diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index c23112b..8432d88 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -124,4 +124,17 @@
+ + +
+
+

财新网滚动新闻

+
财新网滚动新闻 by hillerliao
+

举例:https://rsshub-python.herokuapp.com/caixin/scroll/125

+

路由:/caixin/scroll/:category

+

参数:category [必填,见财新网滚动频道 http://www.caixin.com/search/scroll/0.jsp]

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