前段时间发过帖子 批量下载公众号文章里的音频和视频,今天再说说批量下载公众号话题,以这个话题为例,先复制话题链接:
代码示例:
[Asm] 纯文本查看 复制代码 topic_url=input("输入话题链接")
biz=re.search(r'__biz=(.*?)&',topic_url).group(1)
album_id=re.search(r'album_id=(.*?)&',topic_url).group(1)
response = requests.get(topic_url, headers=headers)
response = requests.get(topic_url, headers=headers)
voiceids = re.findall('data-voiceid="(.*)"',response.text)
msgids = re.findall('data-msgid="(.*)"',response.text)
links = re.findall('data-link="(.*)"',response.text)
titles = re.findall('data-title="(.*)" data-voiceid',response.text)
print(titles,len(voiceids))
for i,j in zip(titles,voiceids):
voice_url = f'https://res.wx.qq.com/voice/getvoice?mediaid={j}'
# print(i,voice_url)
audio_data = requests.get(voice_url,headers=headers)
print('正在下载音频:'+i+'.mp3')
with open(i+'.mp3','wb') as f:
f.write(audio_data.content)
输入话题链接 ,下载效果,下载视频一样的:
|