mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-18 23:16:49 +00:00
add feed - ctolib
This commit is contained in:
@@ -37,3 +37,10 @@ def filter_content(ctx):
|
|||||||
def chuansongme_articles(category=''):
|
def chuansongme_articles(category=''):
|
||||||
from rsshub.spiders.chuansongme.articles import ctx
|
from rsshub.spiders.chuansongme.articles import ctx
|
||||||
return render_template('main/atom.xml', **filter_content(ctx(category)))
|
return render_template('main/atom.xml', **filter_content(ctx(category)))
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/ctolib/topics/<string:category>')
|
||||||
|
@bp.route('/ctolib/topics')
|
||||||
|
def ctolib_topics(category=''):
|
||||||
|
from rsshub.spiders.ctolib.topics import ctx
|
||||||
|
return render_template('main/atom.xml', **filter_content(ctx(category)))
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ def ctx(category=''):
|
|||||||
posts = tree.css('.feed_body .pagedlist_item')
|
posts = tree.css('.feed_body .pagedlist_item')
|
||||||
return {
|
return {
|
||||||
'title': '传送门',
|
'title': '传送门',
|
||||||
'link': 'https://chuansongme.com',
|
'link': domain,
|
||||||
'description': '传送门:微信公众号订阅',
|
'description': '传送门:微信公众号订阅',
|
||||||
'author': 'alphardex',
|
'author': 'alphardex',
|
||||||
'items': list(map(parse, posts))
|
'items': list(map(parse, posts))
|
||||||
|
|||||||
23
rsshub/spiders/ctolib/topics.py
Normal file
23
rsshub/spiders/ctolib/topics.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from rsshub.utils import fetch
|
||||||
|
|
||||||
|
domain = 'https://www.ctolib.com'
|
||||||
|
|
||||||
|
|
||||||
|
def parse(post):
|
||||||
|
item = {}
|
||||||
|
item['title'] = post.css('a.title::text').extract_first()
|
||||||
|
item['description'] = post.css('p.abstract::text').extract_first()
|
||||||
|
item['link'] = f"{domain}{post.css('a.title::attr(href)').extract_first()}"
|
||||||
|
return item
|
||||||
|
|
||||||
|
|
||||||
|
def ctx(category=''):
|
||||||
|
tree = fetch(f'{domain}/python/topics/{category}')
|
||||||
|
posts = tree.css('ul.note-list li')
|
||||||
|
return {
|
||||||
|
'title': 'CTOLib码库',
|
||||||
|
'link': domain,
|
||||||
|
'description': 'Python开发社区',
|
||||||
|
'author': 'alphardex',
|
||||||
|
'items': list(map(parse, posts))
|
||||||
|
}
|
||||||
@@ -29,4 +29,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
<div class="card text-left">
|
||||||
|
<div class="card-body">
|
||||||
|
<h4 class="card-title">CTOLib</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/ctolib/topics" target="_blank">https://rsshub-python.herokuapp.com/ctolib/topics</a></p>
|
||||||
|
<p class="card-text">路由:<code>/ctolib/topics/:category</code></p>
|
||||||
|
<p class="card-text">参数:category [默认为“默认排序”]</p>
|
||||||
|
<table class="table table-bordered table-sm">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
{% for th in ['最新发布', '优质主题'] %}
|
||||||
|
<th>{{th}}</th>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
{% for td in ['last', 'popular']%}
|
||||||
|
<td>{{td}}</td>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
Reference in New Issue
Block a user