财新网滚动新闻

This commit is contained in:
hillerliao
2020-03-08 14:01:28 +08:00
parent 527bdb190c
commit 468ba996e7
3 changed files with 44 additions and 1 deletions

View File

@@ -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))
}