From e8ffba0776fe70d71b90b057015fb3c0dd5f771b Mon Sep 17 00:00:00 2001 From: hillerliao Date: Sun, 15 May 2022 13:48:54 +0800 Subject: [PATCH] add bjnews --- rsshub/spiders/bjnews/channel.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 rsshub/spiders/bjnews/channel.py diff --git a/rsshub/spiders/bjnews/channel.py b/rsshub/spiders/bjnews/channel.py new file mode 100644 index 0000000..76cee2b --- /dev/null +++ b/rsshub/spiders/bjnews/channel.py @@ -0,0 +1,25 @@ +from rsshub.utils import fetch + +domain = 'http://www.bjnews.com.cn' + + +def parse(post): + item = {} + item['description'] = item['title'] = post.css('a::text').extract_first() + item['link'] = post.css('a::attr(href)').extract_first() + return item + + +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() + return { + 'title': channel_title, + 'link': r_url, + 'description': '新京报频道新闻', + 'author': 'hillerliao', + 'items': list(map(parse, posts)) + } \ No newline at end of file