mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-14 23:16:50 +00:00
add mp recommended tag
This commit is contained in:
31
rsshub/spiders/mp/rtag.py
Normal file
31
rsshub/spiders/mp/rtag.py
Normal 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))
|
||||
}
|
||||
Reference in New Issue
Block a user