mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-14 15:09:23 +00:00
add infoq topic
This commit is contained in:
@@ -15,7 +15,7 @@ def parse(post):
|
||||
def ctx():
|
||||
DEFAULT_HEADERS.update({'Referer': 'https://www.infoq.cn'}) # 必须设置Referer,不然会451错误
|
||||
import json
|
||||
posts = requests.post(f'{domain}/public/v1/my/recommond', data={'size': 20}, headers=DEFAULT_HEADERS)
|
||||
posts = requests.post(f'{domain}/public/v1/my/recommond', json={'size': 20}, headers=DEFAULT_HEADERS)
|
||||
posts = json.loads(posts.text)['data']
|
||||
return {
|
||||
'title': 'infoq',
|
||||
|
||||
29
rsshub/spiders/infoq/topic.py
Normal file
29
rsshub/spiders/infoq/topic.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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(category=''):
|
||||
referer = f'{domain}/topic/{category}'
|
||||
DEFAULT_HEADERS.update({'Referer': referer})
|
||||
url = f'{domain}/public/v1/article/getList'
|
||||
import json
|
||||
posts = requests.post(url, json={'size': 20, 'id': category, 'type': 0}, headers=DEFAULT_HEADERS)
|
||||
|
||||
posts = json.loads(posts.text)['data']
|
||||
return {
|
||||
'title': f'{category} - topic - infoq',
|
||||
'link': referer,
|
||||
'description': 'InfoQ - 促进软件开发领域知识与创新的传播',
|
||||
'author': 'hillerliao',
|
||||
'items': list(map(parse, posts))
|
||||
}
|
||||
Reference in New Issue
Block a user