From 16c001c3002d2077f84ab840d383f037b5ab6f9c Mon Sep 17 00:00:00 2001 From: hillerliao Date: Sun, 15 May 2022 14:41:25 +0800 Subject: [PATCH] optimize bjnews --- rsshub/blueprints/main.py | 5 +++++ rsshub/spiders/bjnews/channel.py | 8 ++++---- rsshub/templates/main/feeds.html | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index e0283a2..630dbed 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -215,6 +215,11 @@ def yfchuhai_express(): from rsshub.spiders.yfchuhai.express import ctx return render_template('main/atom.xml', **filter_content(ctx())) +@bp.route('/bjnews/') +def bjnews_channel(category=''): + from rsshub.spiders.bjnews.channel import ctx + return render_template('main/atom.xml', **filter_content(ctx(category))) + ''' @bp.route('/test') @bp.route('/test/测试') diff --git a/rsshub/spiders/bjnews/channel.py b/rsshub/spiders/bjnews/channel.py index 76cee2b..b7a2b93 100644 --- a/rsshub/spiders/bjnews/channel.py +++ b/rsshub/spiders/bjnews/channel.py @@ -14,12 +14,12 @@ def ctx(category=''): r_url = f"{domain}/{category}" tree = fetch(r_url) html = tree.css('body') - posts = tree.css('.list-a') - channel_title = html.css('a.cur::text').extract_first() + posts = tree.css('.list-a').css('li') + channel_title = html.css('a.cur::text').extract_first().strip() return { - 'title': channel_title, + 'title': f'{channel_title} - 新京报', 'link': r_url, - 'description': '新京报频道新闻', + 'description': f'新京报「{channel_title}」频道新闻', '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 10d1110..e51f920 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -145,7 +145,7 @@
东方财富网行业/个股研报 by hillerliao

举例:https://rsshub.deta.dev/eastmoney/report/stock/473

路由:/eastmoney/report/:type/:category

-

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

+

参数:type, category [必填,见东方财富网研报频道 ]


@@ -394,6 +394,19 @@
+ +
+
+

新京报 - 频道

+
新京报 - 频道by hillerliao
+

举例:https://rsshub.deta.dev/bjnews/beijing

+

路由:/bjnews/:channelid

+

channelid [必填, 频道 id]

+
+
+
+ +