eastmoney report

This commit is contained in:
hillerliao
2020-03-08 22:53:50 +08:00
parent 468ba996e7
commit 37dddb4ac7
3 changed files with 44 additions and 1 deletions

View File

@@ -94,4 +94,9 @@ def csrc_audit(category=''):
@bp.route('/caixin/scroll/<string:category>')
def caixin_scroll(category=''):
from rsshub.spiders.caixin.scroll import ctx
return render_template('main/atom.xml', **filter_content(ctx(category)))
return render_template('main/atom.xml', **filter_content(ctx(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)))

View File

@@ -0,0 +1,37 @@
import requests
import json
from parsel import Selector
from datetime import datetime, date
from rsshub.utils import DEFAULT_HEADERS
def parse(post):
item = {}
if post['stockName']!='':
post['stockName'] = '[' + post['stockName'] + '] '
item['title'] = post['stockName'] + ' ' + post['title']
item['title'] = item['title'].strip()
item['description'] = item['title']
item['link'] = f"http://data.eastmoney.com/report/zw_industry.jshtml?encodeUrl={post['encodeUrl']}"
item['author'] = post['orgSName'] + ' ' + post['researcher']
item['pubDate'] = post['publishDate']
return item
def ctx(type='', category=''):
qTypes = {'industry': '1', 'stock': '0'}
qType = qTypes[type]
url = f'http://reportapi.eastmoney.com/report/list?\
cb=&industryCode={category}\
&pageSize=50&industry=*&rating=*&ratingChange=*\
&beginTime=&endTime=&pageNo=1&fields=&qType={qType}&orgCode=&rcode=&_=1583647953800'
res = requests.get(url)
posts = json.loads(res.text)['data']
items = list(map(parse, posts))
return {
'title': f'{category} {type}研报 - 东方财富网',
'link': f'http://data.eastmoney.com/report/{type}.jshtml?hyid={category}',
'description': f'{category} {type} 研报 - 东方财富网',
'author': 'hillerliao',
'items': items
}

View File

@@ -17,6 +17,7 @@
<updated>{{item.pubDate|default(now)}}</updated>
<link href="{{item.link}}"/>
<content type="html" src="{{item.link}}"><![CDATA[{{item.description|safe}}]]></content>
<author>![CDATA[{{item.author|safe}}]]</author>
</entry>
{% endfor %}
</feed>