# coding:utf-8
#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
import os
import requests
url = 'https://haokan.baidu.com/v?pd=wisenatural&vid=5522921063801883018'
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
}
response = requests.get(url=url, headers=headers)
json_data = response.json()
videos = json_data['data']['response']['videos']
for index in videos:
title = index['title']
play_url = index['play_url']
video_content = requests.get(url=play_url, headers=headers).content
path = 'video\\'
if not os.path.exists(path):
os.mkdir(path)
with open(path + title + '.mp4', mode='wb') as f:
f.write(video_content)
print('正在保存:', title)