lightly init

This commit is contained in:
hillerliao
2022-08-09 18:20:57 +08:00
parent 0001db454e
commit 6608cf1c2b
3 changed files with 41 additions and 35 deletions

View File

@@ -1,25 +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').css('li')
channel_title = html.css('a.cur::text').extract_first().strip()
return {
'title': f'{channel_title} - 新京报',
'link': r_url,
'description': f'新京报「{channel_title}」频道新闻',
'author': 'hillerliao',
'items': list(map(parse, posts))
}
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').css('li')
channel_title = html.css('a.cur::text').extract_first().strip()
return {
'title': f'{channel_title} - 新京报',
'link': r_url,
'description': f'新京报「{channel_title}」频道新闻',
'author': 'hillerliao',
'items': list(map(parse, posts))
}