Files
RSSHub-python/rsshub/spiders/chouti/section.py
2020-10-20 21:15:05 +08:00

28 lines
870 B
Python

import requests
from rsshub.utils import DEFAULT_HEADERS
domain = 'https://dig.chouti.com'
def parse(post):
item = {}
item['title'] = post['title']
item['description'] = f"[{post['sectionName']}] {item['title']} "
item['link'] = 'https://dig.chouti.com/link/' + str(post['id'])
item['pubDate'] = str(post['created_time'])[0:10]
item['author'] = post['submitted_user']['nick']
return item
def ctx(category=''):
DEFAULT_HEADERS.update({'Referer': domain})
post_data = {'sectionId':category}
r_url = f'{domain}/section/links'
posts = requests.post(r_url, data=post_data, headers=DEFAULT_HEADERS).json()['data']
return {
'title': f'{category} - 抽屉热榜',
'link': r_url,
'description': f'抽屉热榜 - {r_url}',
'author': 'hillerliao',
'items': list(map(parse, posts))
}