mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-17 23:16:51 +00:00
add cninfo announcement
This commit is contained in:
@@ -32,6 +32,13 @@ def filter_content(ctx):
|
|||||||
|
|
||||||
|
|
||||||
#---------- feed路由从这里开始 -----------#
|
#---------- feed路由从这里开始 -----------#
|
||||||
|
@bp.route('/cninfo/announcement/<string:stock_id>/<string:category>')
|
||||||
|
@bp.route('/cninfo/announcement')
|
||||||
|
def cninfo_announcement(stock_id='', category=''):
|
||||||
|
from rsshub.spiders.cninfo.announcement import ctx
|
||||||
|
return render_template('main/atom.xml', **filter_content(ctx(stock_id,category)))
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/chuansongme/articles/<string:category>')
|
@bp.route('/chuansongme/articles/<string:category>')
|
||||||
@bp.route('/chuansongme/articles')
|
@bp.route('/chuansongme/articles')
|
||||||
def chuansongme_articles(category=''):
|
def chuansongme_articles(category=''):
|
||||||
|
|||||||
49
rsshub/spiders/cninfo/announcement.py
Normal file
49
rsshub/spiders/cninfo/announcement.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import requests
|
||||||
|
from rsshub.utils import DEFAULT_HEADERS
|
||||||
|
|
||||||
|
domain = 'http://www.cninfo.com.cn'
|
||||||
|
|
||||||
|
|
||||||
|
def parse(post):
|
||||||
|
item = {}
|
||||||
|
item['title'] = post['secName'] + '(' + post['secCode'] + ')' + ': ' + post['announcementTitle']
|
||||||
|
item['description'] = item['title']
|
||||||
|
item['link'] = 'http://static.cninfo.com.cn/' + post['adjunctUrl']
|
||||||
|
item['pubDate'] = post['announcementTime']
|
||||||
|
return item
|
||||||
|
|
||||||
|
|
||||||
|
def ctx(stock_id='', category=''):
|
||||||
|
stock_id = '' if stock_id == 'all' else stock_id
|
||||||
|
stock_name = ''
|
||||||
|
stock_list = requests.get('http://www.cninfo.com.cn/new/data/szse_stock.json', headers=DEFAULT_HEADERS).json()['stockList']
|
||||||
|
for stock in stock_list:
|
||||||
|
if stock['code'] == stock_id :
|
||||||
|
stock_id = stock['orgId']
|
||||||
|
stock_name = stock['zwjc']
|
||||||
|
break
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
nowtime = datetime.datetime.now()
|
||||||
|
deltaday=datetime.timedelta(days=1)
|
||||||
|
start_date = datetime.datetime.strftime(nowtime- 5 * deltaday, '%Y-%m-%d')
|
||||||
|
end_date = datetime.datetime.strftime(nowtime + 2 * deltaday, '%Y-%m-%d')
|
||||||
|
seDate = start_date + '~' + end_date
|
||||||
|
|
||||||
|
searchkey = ''
|
||||||
|
if '_' in category:
|
||||||
|
searchkey = category.split('_')[-1]
|
||||||
|
category = category.split('_')[0]
|
||||||
|
|
||||||
|
|
||||||
|
DEFAULT_HEADERS.update({'Referer': domain})
|
||||||
|
posts = requests.post(f'{domain}/new/hisAnnouncement/query', \
|
||||||
|
data={'pageSize': '30','tabName':'fulltext', 'plate': '', 'category':f'category_{category}_szsh', \
|
||||||
|
'secid': stock_id,'seDate':'', 'seDate': seDate, 'searchkey': searchkey }, headers=DEFAULT_HEADERS).json()['announcements']
|
||||||
|
return {
|
||||||
|
'title': f'{stock_name}-{category}-公告-巨潮资讯',
|
||||||
|
'link': f'{domain}/new/commonUrl/pageOfSearch?url=disclosure/list/search&checkedCategory=category_{category}_szsh&searchkey={searchkey}',
|
||||||
|
'description': f'{stock_name}关于{category}的公告-巨潮资讯',
|
||||||
|
'author': 'hillerliao',
|
||||||
|
'items': list(map(parse, posts))
|
||||||
|
}
|
||||||
@@ -64,4 +64,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
<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/cninfo/announcement/all/gqjl" target="_blank">https://rsshub-python.herokuapp.com/cninfo/announcement/all/gqjl</a></p>
|
||||||
|
<p class="card-text">举例:<a href="https://rsshub-python.herokuapp.com/cninfo/announcement/all/gqbd_预披露" target="_blank">https://rsshub-python.herokuapp.com/cninfo/announcement/all/gqbd_预披露</a>,股权变动类公告中标题含有「预披露」的公告</p>
|
||||||
|
<p class="card-text">路由:<code>/cninfo/announcement/:stock_id/:category</code></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
Reference in New Issue
Block a user