diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index e2445c5..8689194 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -230,6 +230,11 @@ def appstore_top(cc='', genreid=''): from rsshub.spiders.appstore.top import ctx return render_template('main/atom.xml', **filter_content(ctx(cc,genreid))) +@bp.route('/netease/comment/') +def netease_comment(category=''): + from rsshub.spiders.netease.comment import ctx + return render_template('main/atom.xml', **filter_content(ctx(category))) + @bp.route('/aisixiang/search//') def aisixiang_search(category='', keywords=''): from rsshub.spiders.aisixiang.search import ctx diff --git a/rsshub/spiders/netease/comment.py b/rsshub/spiders/netease/comment.py new file mode 100644 index 0000000..2e995f8 --- /dev/null +++ b/rsshub/spiders/netease/comment.py @@ -0,0 +1,39 @@ +from unicodedata import category +import requests +import json +import arrow +from rsshub.utils import DEFAULT_HEADERS + +domain = 'https://comment.api.163.com/api/v1/products/a2869674571f77b5a0867c3d71db5856' + +type = '' + +def parse(post): + item = {} + item['title'] = '【原文】' + post['thread']['title'] + ' → 【跟贴】' + post['comments'][0]['1']['content'] + item['description'] = '【回帖】' + post['comments'][1]['1']['content'] if len(post['comments']) > 1 \ + else '【回帖】' + post['comments'][0]['2']['content'] if '2' in post['comments'][0] \ + else '' + item['link'] = post['thread']['url'] + item['author'] = '' + item['pubDate'] = arrow.now().isoformat() + return item + + +def ctx(category=''): + type = category + paths = {"heated":"/heatedList/allSite?ibc=newspc&page=1", + "splendid":"/recommendList/single?ibc=newspc&offset=0&limit=30", + "build":"/recommendList/build?ibc=newspc&offset=0&limit=15&showLevelThreshold=72"} + url = domain + paths[category] + res = requests.get(url, headers=DEFAULT_HEADERS) + res = json.loads(res.text) + posts = res + items = list(map(parse, posts)) + return { + 'title': f'{category} - 网易跟贴', + 'link': "https://comment.163.com/#/" + category, + 'description': f'{category} - 网易跟贴', + 'author': 'hillerliao', + 'items': items + } diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index c4c6f86..a86a44b 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -195,6 +195,19 @@
+ +
+
+

网易跟贴

+
网易跟贴 by hillerliao
+

举例:https://pyrsshub.vercel.app/netease/comment/heated

+

路由:/netease/comment/:category

+

参数:category [必填, heated|build|splendid]

+
+
+
+ +