mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-22 23:16:48 +00:00
add xuangubao theme
This commit is contained in:
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
|
||||
}
|
||||
Reference in New Issue
Block a user