add mp recommended tag

This commit is contained in:
hillerliao
2023-02-26 20:58:08 +08:00
parent 2013e37398
commit ad2f247833
5 changed files with 646 additions and 97 deletions

View File

@@ -204,6 +204,11 @@ def mp_tag(mp='', tag=''):
from rsshub.spiders.mp.tag import ctx
return render_template('main/atom.xml', **filter_content(ctx(mp,tag)))
@bp.route('/mp/rtag/<string:c1>/<string:tag>')
def mp_rtag(c1='', tag=''):
from rsshub.spiders.mp.rtag import ctx
return render_template('main/atom.xml', **filter_content(ctx(c1, tag)))
@bp.route('/producthunt/search/<string:keyword>/<string:period>')
def producthunt_search(keyword='', period=''):
from rsshub.spiders.producthunt.search import ctx

31
rsshub/spiders/mp/rtag.py Normal file
View File

@@ -0,0 +1,31 @@
import requests
from bs4 import BeautifulSoup
import pyjsparser
domain = 'https://mp.weixin.qq.com'
def parse(post):
item = {}
item['title'] = post['properties'][4]['value']['value']
item['description'] = post['properties'][5]['value']['value']
item['link'] = post['properties'][6]['value']['value']
item['pubDate'] = post['properties'][16]['value']['left']['value']
test = item['author'] = post['properties'][1]['value']['properties'][0]['value']['value']
return item
def ctx(c1='', tag=''):
url = f"{domain}/mp/recommendtag?c1={c1}&tag={tag}&msg_type=1&sn=2fGf6B-xDlazPj5_t_KgEH0Gpkw"
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
scripts = soup.findAll("script")[12].text
scripts = scripts.split('mp_msgs: ')[-1].split('isSubscribed')[0][:-6]
posts = pyjsparser.parse(scripts)['body'][0]['expression']['elements']
return {
'title': f'{tag} - 微信公众号推荐话题',
'link': url,
'description': f'{tag} - 微信公众号推荐话题',
'author': 'hillerliao',
'items': list(map(parse, posts))
}

View File

@@ -486,6 +486,19 @@
<br>
<!--item info end-->
<!--item info start-->
<div class="card text-left">
<div class="card-body">
<h4 class="card-title">微信公众号 - 推荐标签文章列表</h4>
<h6 class="text-muted">微信公众号 - 推荐标签文章列表 <a href="https://github.com/hillerliao" target="_blank" class="badge badge-secondary">by hillerliao</a></h6>
<p class="card-text">举例:<a href="https://pyrsshub.vercel.app/mp/rtag/科技/ChatGPT" target="_blank">https://pyrsshub.vercel.app/mp/rtag/科技/ChatGPT</a></p>
<p class="card-text">路由:<code>/mp/rtag/:c1/:tag</code></p>
<p class="card-text">c1 [必填, 分类]tag[必填, 标签 id] </p>
</div>
</div>
<br>
<!--item info end-->
<!--item info start-->
<div class="card text-left">
<div class="card-body">
@@ -551,4 +564,5 @@
<br>
<!--item info end-->
{% endblock content %}