mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-15 23:16:48 +00:00
fetch infoq author article
This commit is contained in:
@@ -68,6 +68,10 @@ def infoq_topic(category=''):
|
|||||||
from rsshub.spiders.infoq.topic import ctx
|
from rsshub.spiders.infoq.topic import ctx
|
||||||
return render_template('main/atom.xml', **filter_content(ctx(category)))
|
return render_template('main/atom.xml', **filter_content(ctx(category)))
|
||||||
|
|
||||||
|
@bp.route('/infoq/profile/<string:category>')
|
||||||
|
def infoq_profile(category=''):
|
||||||
|
from rsshub.spiders.infoq.profile import ctx
|
||||||
|
return render_template('main/atom.xml', **filter_content(ctx(category)))
|
||||||
|
|
||||||
@bp.route('/dxzg/notice')
|
@bp.route('/dxzg/notice')
|
||||||
def dxzg_notice():
|
def dxzg_notice():
|
||||||
|
|||||||
32
rsshub/spiders/infoq/profile.py
Normal file
32
rsshub/spiders/infoq/profile.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from rsshub.utils import DEFAULT_HEADERS
|
||||||
|
from rsshub.utils import fetch
|
||||||
|
|
||||||
|
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']}"
|
||||||
|
item['pubDate'] = post['publish_time']
|
||||||
|
return item
|
||||||
|
|
||||||
|
|
||||||
|
def ctx(category=''):
|
||||||
|
referer = f'{domain}/profile/{category}/publish'
|
||||||
|
DEFAULT_HEADERS.update({'Referer': referer})
|
||||||
|
url = f'{domain}/public/v1/user/getListByAuthor'
|
||||||
|
posts = requests.post(url, json={'size': 12, 'id': category, 'type': 0}, headers=DEFAULT_HEADERS)
|
||||||
|
tree = fetch(referer,headers=DEFAULT_HEADERS)
|
||||||
|
feed_title = tree.css('title::text').get()
|
||||||
|
posts = json.loads(posts.text)['data']
|
||||||
|
return {
|
||||||
|
'title': f'{feed_title} - Profile - InfoQ',
|
||||||
|
'link': referer,
|
||||||
|
'description': 'InfoQ - 促进软件开发领域知识与创新的传播',
|
||||||
|
'author': 'hillerliao',
|
||||||
|
'items': list(map(parse, posts))
|
||||||
|
}
|
||||||
@@ -118,6 +118,10 @@
|
|||||||
<h6 class="text-muted">主题内容 <a href="https://github.com/hillerliao" target="_blank" class="badge badge-secondary">by hillerliao</a></h6>
|
<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://pyrsshub.vercel.app/infoq/topic/159" target="_blank">https://pyrsshub.vercel.app/infoq/topic/159</a></p>
|
<p class="card-text">举例:<a href="https://pyrsshub.vercel.app/infoq/topic/159" target="_blank">https://pyrsshub.vercel.app/infoq/topic/159</a></p>
|
||||||
<p class="card-text">路由:<code>/infoq/topic/:category</code></p>
|
<p class="card-text">路由:<code>/infoq/topic/:category</code></p>
|
||||||
|
|
||||||
|
<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://pyrsshub.vercel.app/infoq/profile/8D1F7C1F2C23FD" target="_blank">https://pyrsshub.vercel.app/infoq/profile/8D1F7C1F2C23FD</a></p>
|
||||||
|
<p class="card-text">路由:<code>/infoq/profile/:category</code></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user