mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-14 07:26:44 +00:00
add feed - infoq
This commit is contained in:
@@ -44,3 +44,9 @@ def chuansongme_articles(category=''):
|
|||||||
def ctolib_topics(category=''):
|
def ctolib_topics(category=''):
|
||||||
from rsshub.spiders.ctolib.topics import ctx
|
from rsshub.spiders.ctolib.topics 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/recommend')
|
||||||
|
def infoq_recommend():
|
||||||
|
from rsshub.spiders.infoq.recommend import ctx
|
||||||
|
return render_template('main/atom.xml', **filter_content(ctx()))
|
||||||
|
|||||||
24
rsshub/spiders/infoq/recommend.py
Normal file
24
rsshub/spiders/infoq/recommend.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
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))
|
||||||
|
}
|
||||||
@@ -55,4 +55,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
<div class="card text-left">
|
||||||
|
<div class="card-body">
|
||||||
|
<h4 class="card-title">InfoQ</h4>
|
||||||
|
<h6 class="text-muted">推荐内容 <a href="https://github.com/alphardex" target="_blank" class="badge badge-secondary">by alphardex</a></h6>
|
||||||
|
<p class="card-text">举例:<a href="https://rsshub-python.herokuapp.com/infoq/recommend" target="_blank">https://rsshub-python.herokuapp.com/infoq/recommend</a></p>
|
||||||
|
<p class="card-text">路由:<code>/infoq/recommend</code></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
Reference in New Issue
Block a user