diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index e3a5d27..3b5af73 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -37,3 +37,10 @@ def filter_content(ctx): def chuansongme_articles(category=''): from rsshub.spiders.chuansongme.articles import ctx return render_template('main/atom.xml', **filter_content(ctx(category))) + + +@bp.route('/ctolib/topics/') +@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))) diff --git a/rsshub/spiders/chuansongme/articles.py b/rsshub/spiders/chuansongme/articles.py index ae15a08..3040ff8 100644 --- a/rsshub/spiders/chuansongme/articles.py +++ b/rsshub/spiders/chuansongme/articles.py @@ -16,7 +16,7 @@ def ctx(category=''): posts = tree.css('.feed_body .pagedlist_item') return { 'title': '传送门', - 'link': 'https://chuansongme.com', + 'link': domain, 'description': '传送门:微信公众号订阅', 'author': 'alphardex', 'items': list(map(parse, posts)) diff --git a/rsshub/spiders/ctolib/topics.py b/rsshub/spiders/ctolib/topics.py new file mode 100644 index 0000000..aadc255 --- /dev/null +++ b/rsshub/spiders/ctolib/topics.py @@ -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)) + } \ No newline at end of file diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index d68ad73..65690bc 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -29,4 +29,30 @@
+
+
+

CTOLib

+
话题 by alphardex
+

举例:https://rsshub-python.herokuapp.com/ctolib/topics

+

路由:/ctolib/topics/:category

+

参数:category [默认为“默认排序”]

+ + + + {% for th in ['最新发布', '优质主题'] %} + + {% endfor %} + + + + + {% for td in ['last', 'popular']%} + + {% endfor %} + + +
{{th}}
{{td}}
+
+
+
{% endblock content %} \ No newline at end of file