mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-18 15:09:34 +00:00
flake8 style check for jiemian newsflash
This commit is contained in:
@@ -5,30 +5,36 @@ from datetime import datetime, date
|
|||||||
|
|
||||||
domain = 'https://jiemian.com'
|
domain = 'https://jiemian.com'
|
||||||
|
|
||||||
|
|
||||||
def parse(post):
|
def parse(post):
|
||||||
item = {}
|
item = {}
|
||||||
item['title'] = post.css('a::text').extract_first()
|
item['title'] = post.css('a::text').extract_first()
|
||||||
item['description'] = post.css('p::text').extract()[-1].strip('】\n\t\t\t\t\t')
|
item['description'] = post.css('p::text').extract()[-1]\
|
||||||
|
.strip('】\n\t\t\t\t\t')
|
||||||
item['link'] = post.css('a::attr(href)').extract_first()
|
item['link'] = post.css('a::attr(href)').extract_first()
|
||||||
pubdate = post.xpath('//div[@class="item-news "]/preceding::div[@class="col-date"][last()-1]').css('div::text').extract_first()
|
pubdate = post.xpath('//div[@class="item-news "]/\
|
||||||
cur_t =datetime.now().time().strftime("%H%M")
|
preceding::div[@class="col-date"][last()-1]')\
|
||||||
|
.css('div::text').extract_first()
|
||||||
|
cur_t = datetime.now().time().strftime("%H%M")
|
||||||
pub_t = post.css('.item-date').css('div::text').extract_first()
|
pub_t = post.css('.item-date').css('div::text').extract_first()
|
||||||
if pub_t.replace(':', '') < cur_t:
|
if pub_t.replace(':', '') < cur_t:
|
||||||
pubdate = date.today().isoformat()
|
pubdate = date.today().isoformat()
|
||||||
item['pubDate'] = pubdate + ' ' + pub_t
|
item['pubDate'] = pubdate + ' ' + pub_t
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
|
||||||
def ctx(category=''):
|
def ctx(category=''):
|
||||||
res = requests.get(f"https://a.jiemian.com/index.php?m=lists&a=ajaxNews&page=1&cid={category}")
|
res = requests.get(f"https://a.jiemian.com/index.php?\
|
||||||
|
m=lists&a=ajaxNews&page=1&cid={category}")
|
||||||
res = res.text[1:-1]
|
res = res.text[1:-1]
|
||||||
res = json.loads(res)['rst']
|
res = json.loads(res)['rst']
|
||||||
tree = Selector(text=res)
|
tree = Selector(text=res)
|
||||||
posts = tree.css('.item-news')
|
posts = tree.css('.item-news')
|
||||||
items = list(map(parse, posts))
|
items = list(map(parse, posts))
|
||||||
return {
|
return {
|
||||||
'title': f'{category} 快讯 - 界面新闻',
|
'title': f'{category} 快讯 - 界面新闻',
|
||||||
'link': f'{domain}//lists/{category}.html',
|
'link': f'{domain}//lists/{category}.html',
|
||||||
'description': f'{category} 快讯 - 界面新闻',
|
'description': f'{category} 快讯 - 界面新闻',
|
||||||
'author': 'hillerliao',
|
'author': 'hillerliao',
|
||||||
'items': items
|
'items': items
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user