mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-14 15:09:23 +00:00
add jiemian newsflash
This commit is contained in:
@@ -81,3 +81,7 @@ def earningsdate_businesswire():
|
||||
from rsshub.spiders.earningsdate.businesswire import ctx
|
||||
return render_template('main/atom.xml', **filter_content(ctx()))
|
||||
|
||||
@bp.route('/jiemian/newsflash/<string:category>')
|
||||
def jiemian_newsflash(category=''):
|
||||
from rsshub.spiders.jiemian.newsflash import ctx
|
||||
return render_template('main/atom.xml', **filter_content(ctx(category)))
|
||||
34
rsshub/spiders/jiemian/newsflash.py
Normal file
34
rsshub/spiders/jiemian/newsflash.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import requests
|
||||
import json
|
||||
from parsel import Selector
|
||||
from datetime import datetime, date
|
||||
|
||||
domain = 'https://jiemian.com'
|
||||
|
||||
def parse(post):
|
||||
item = {}
|
||||
item['title'] = post.css('a::text').extract_first()
|
||||
item['description'] = post.css('p::text').extract()[-1].strip('】\n\t\t\t\t\t')
|
||||
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()
|
||||
cur_t =datetime.now().time().strftime("%H%M")
|
||||
pub_t = post.css('.item-date').css('div::text').extract_first()
|
||||
if pub_t.replace(':', '') < cur_t:
|
||||
pubdate = date.today().isoformat()
|
||||
item['pubDate'] = pubdate + ' ' + pub_t
|
||||
return item
|
||||
|
||||
def ctx(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 = json.loads(res)['rst']
|
||||
tree = Selector(text=res)
|
||||
posts = tree.css('.item-news')
|
||||
items = list(map(parse, posts))
|
||||
return {
|
||||
'title': f'{category} 快讯 - 界面新闻',
|
||||
'link': f'{domain}//lists/{category}.html',
|
||||
'description': f'{category} 快讯 - 界面新闻',
|
||||
'author': 'hillerliao',
|
||||
'items': items
|
||||
}
|
||||
@@ -98,4 +98,17 @@
|
||||
</div>
|
||||
<br>
|
||||
<!--item info end-->
|
||||
|
||||
<!--item info start-->
|
||||
<div class="card text-left">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">界面快讯</h4>
|
||||
<h6 class="text-muted">界面快讯 <a href="https://github.com/hillerliao" target="_blank" class="badge badge-secondary">by hillerliao</a></h6>
|
||||
<p class="card-text">举例:<a href="https://rsshub-python.herokuapp.com/jiemian/newsflash/166" target="_blank">https://rsshub-python.herokuapp.com/jiemian/newsflash/166</a></p>
|
||||
<p class="card-text">路由:<code>/jiemian/newsflash/:category</code></p>
|
||||
<p class="card-text">参数:category [必填,见界面快讯栏目https://www.jiemian.com/lists/4.html]</p>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<!--item info end-->
|
||||
{% endblock content %}
|
||||
Reference in New Issue
Block a user