Files
RSSHub-python/rsshub/spiders/infoq/recommend.py
2019-01-25 14:59:25 +08:00

24 lines
824 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import requests
from rsshub.utils import DEFAULT_HEADERS
domain = 'https://www.infoq.cn'
def parse(post):
item = {}
item['title'] = post['article_title']
item['description'] = f"{post['article_summary']}<br><img referrerpolicy='no-referrer' src={post.get('article_cover')}>"
item['link'] = f"{domain}/article/{post['uuid']}"
return item
def ctx():
DEFAULT_HEADERS.update({'Referer': 'https://www.infoq.cn'}) # 必须设置Referer不然会451错误
posts = requests.post(f'{domain}/public/v1/my/recommond', data={'size': 20}, headers=DEFAULT_HEADERS).json()['data']
return {
'title': 'infoq',
'link': domain,
'description': 'InfoQ - 促进软件开发领域知识与创新的传播',
'author': 'alphardex',
'items': list(map(parse, posts))
}