Files
RSSHub-python/rsshub/spiders/caixin/scroll.py
2020-03-08 14:01:28 +08:00

25 lines
759 B
Python

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