mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-14 07:26:44 +00:00
add xuangubao theme
This commit is contained in:
@@ -99,4 +99,9 @@ def caixin_scroll(category=''):
|
||||
@bp.route('/eastmoney/report/<string:type>/<string:category>')
|
||||
def eastmoney_report(category='', type=''):
|
||||
from rsshub.spiders.eastmoney.report import ctx
|
||||
return render_template('main/atom.xml', **filter_content(ctx(type,category)))
|
||||
return render_template('main/atom.xml', **filter_content(ctx(type,category)))
|
||||
|
||||
@bp.route('/xuangubao/<string:type>/<string:category>')
|
||||
def xuangubao_xuangubao(type='', category=''):
|
||||
from rsshub.spiders.xuangubao.xuangubao import ctx
|
||||
return render_template('main/atom.xml', **filter_content(ctx(type, category)))
|
||||
31
rsshub/spiders/xuangubao/xuangubao.py
Normal file
31
rsshub/spiders/xuangubao/xuangubao.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import requests
|
||||
import json
|
||||
from rsshub.utils import DEFAULT_HEADERS
|
||||
|
||||
|
||||
def parse(post):
|
||||
item = {}
|
||||
item['title'] = post['Title']
|
||||
item['description'] = post['Summary'] if post['Summary'] != '' else post['Title']
|
||||
item['link'] = post['OriginalUrl'] if post['OriginalUrl'] != '' else post['Url'] if post['Url'] !='' else post['ShareUrl2']
|
||||
item['author'] = post['Source'] + post['DisplayAuthor']
|
||||
item['pubDate'] = post['CreatedAt']
|
||||
return item
|
||||
|
||||
|
||||
def ctx(type='', category=''):
|
||||
api_subpath = 'bkjMsgs' if type=='theme' else 'subj'
|
||||
url = f'https://api.xuangubao.cn/api/pc/{api_subpath}/{category}?limit=20'
|
||||
print(url)
|
||||
res = requests.get(url)
|
||||
res = json.loads(res.text)
|
||||
posts = res['Messages']
|
||||
theme_name = res['BkjName'] if type=='theme' else res['Subject']['Title']
|
||||
items = list(map(parse, posts))
|
||||
return {
|
||||
'title': f'{theme_name} - 主题 - 选股宝',
|
||||
'link': f'https://xuangubao.cn/subject/bkj/{category}',
|
||||
'description': f'{theme_name} 板块/主题动态 - 选股宝',
|
||||
'author': 'hillerliao',
|
||||
'items': items
|
||||
}
|
||||
@@ -137,4 +137,30 @@
|
||||
</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/eastmoney/report/stock/473" target="_blank">https://rsshub-python.herokuapp.com/eastmoney/report/stock/473</a></p>
|
||||
<p class="card-text">路由:<code>/eastmoney/report/:type/:category</code></p>
|
||||
<p class="card-text">参数:type, category [必填,见财新网滚动频道 http://www.caixin.com/search/scroll/0.jsp]</p>
|
||||
</div>
|
||||
</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/xuangubao/theme/17006066" target="_blank">https://rsshub-python.herokuapp.com/xuangubao/theme/17006066</a></p>
|
||||
<p class="card-text">路由:<code>/xuangubao/:type/:category</code></p>
|
||||
<p class="card-text">参数:type = theme|subject, category [必填,板块/主题ID]</p>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<!--item info end-->
|
||||
{% endblock content %}
|
||||
Reference in New Issue
Block a user