[Python] 纯文本查看 复制代码 import requests
import re
url = 'https://v.huya.com/g/all?set_id=51'
response = requests.get(url=url)
video_id_list = re.findall('<li data-vid="(\d+)">', response.text)
for video_id in video_id_list:
link = f'https://liveapi.huya.com/moment/getMomentContent?videoId={video_id}&uid=&_=1665144759951'
response_1 = requests.get(url=link)
title = response_1.json()['data']['moment']['title']
video_url = response_1.json()['data']['moment']['videoInfo']['definitions'][0]['url']
video_content = requests.get(url=video_url).content
with open('video\\' + title + '.mp4', mode='wb') as f:
f.write(video_content)
print(title, video_url) |