diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index d6f9e03..65f8a51 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -169,3 +169,7 @@ def chouti_section(category=''): def chouti_search(category=''): from rsshub.spiders.chouti.search import ctx return render_template('main/atom.xml', **filter_content(ctx(category))) +@bp.route('/mp/tag//') +def mp_tag(mp='', tag=''): + from rsshub.spiders.mp.tag import ctx + return render_template('main/atom.xml', **filter_content(ctx(mp,tag))) \ No newline at end of file diff --git a/rsshub/spiders/mp/tag.py b/rsshub/spiders/mp/tag.py new file mode 100644 index 0000000..2d92332 --- /dev/null +++ b/rsshub/spiders/mp/tag.py @@ -0,0 +1,27 @@ +from rsshub.utils import fetch + +domain = 'https://mp.weixin.qq.com' + + +def parse(post): + item = {} + item['description'] = item['title'] = post.css('span.album__item-title-wrp::text').extract_first() + link = f"{post.css('li::attr(data-link)').extract_first()}" + item['link'] = link + item['pubDate'] = post.css('span.js_article_create_time::text').extract_first() + return item + + +def ctx(biz='', tag=''): + url = f"{domain}/mp/appmsgalbum?__biz={biz}==&action=getalbum&album_id={tag}" + tree = fetch(url) + posts = tree.css('.js_album_list li') + mp_name = tree.css('div.album__author-name::text').extract_first() + tag_name = tree.css('div#js_tag_name::text').extract_first() + return { + 'title': f'{tag_name} - {mp_name}', + 'link': url, + 'description': f'{tag_name} - {mp_name}', + 'author': 'hillerliao', + '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 a783b43..2ca3fbd 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -309,4 +309,17 @@
+ +
+
+

微信公众号 - 标签文章列表

+
微信公众号 - 标签文章列表 by hillerliao
+

举例:https://pyrsshub.herokuapp.com/mp/tag/MzI5MjM3OTA0MA/1500461858015772673

+

路由:/mp/tag/:biz/:tag

+

biz [必填, 公众号id],tag,[必填, 标签 id]

+
+
+
+ + {% endblock content %}