爬到的下载链接,python下载文件都是1KB,而把链接放到360安全浏览器的下载或者迅雷就可以下载。
想知道是怎么回事。
放几个下载地址:
https://dxc17yp8ltj-video-ali.lycheer.net/d2d58335vodtranssh1253442168/a7fbec1f387702306295739298/v.f100030.mp4?tmp=f30.mp4&auth_key=1668027435-3d8f949ce3-0-5cc1acf263ac82e536a9dc7a0cad8073
https://dxc17yp8ltj-video-ali.lycheer.net/d2d58335vodtranssh1253442168/aa632392387702306295849004/v.f100030.mp4?tmp=f30.mp4&auth_key=1668026840-a9307ac4d5-0-b9c6f4a58a8f310250654602ba1d3e89
打算下载这个地方的视频:
https://m.lizhiweike.com/lecture2/27885251
python 代码(临时写的,代码有点乱,见谅):
[Python] 纯文本查看 复制代码 import requests
import json
r_num = requests.get(
"https://apiv1.lizhiweike.com/api/channel/1321444/lecture_list?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiQWNjb3VudFRva2VuIiwiaWQiOjgzMDE5MTEyLCJuaWNrbmFtZSI6IueIseWQg-eLl-mjn-eahOeMq_CfpJNjaXVtIiwic2V4IjoiMSIsInN0YXR1cyI6Im5vcm1hbCIsInN1YnNjcmliZWQiOjAsInJvbGUiOiJzdHVkZW50IiwidmVyc2lvbiI6IjEuMCIsImF2YXRhcl91cmwiOiJodHRwczovL2ltZy5seWNoZWVyLm5ldC9hdmF0YXIvMWU5YTI5MTA0NzhlYzEyYjMxNWYyZmMzMTIyNTUyNDcvYXZhdGFyIiwidGVsZXBob25lX3ZhbGlkYXRlIjpmYWxzZSwiY2xpZW50X2lwIjoiMzkuMTQ5LjE0LjExMCIsInRva2VuX2tleSI6Ik1DNDROREkzT0RVek1EWTNOakl5TmpNeiIsImlhdCI6MTY2ODAwMjg1OSwiZXhwIjoxNjY4MDI0NDU5fQ.l2qZ3YGGCZ9AcVWRy52dZva66lb3306wBb0MwBodeYI")
ls_num = []
ls_num = r_num.text
string_num = json.loads(ls_num)
ss = string_num["data"]["lectures"]
s = 0
a = {}
b = {}
for i in ss:
a[s] = i["name"]
b[s] = i["id"]
print("第{0}个视频,视频名称为{1},视频编号为{2}".format(s, a[s], b[s]))
s = s + 1
ls = []
ls_dizhi = []
for i in range(0, s):
url_xiazai = "https://apiv1.lizhiweike.com/api/lecture/" + str(b[i]) + "/info?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiQWNjb3VudFRva2VuIiwiaWQiOjgzMDE5MTEyLCJuaWNrbmFtZSI6IueIseWQg-eLl-mjn-eahOeMq_CfpJNjaXVtIiwic2V4IjoiMSIsInN0YXR1cyI6Im5vcm1hbCIsInN1YnNjcmliZWQiOjAsInJvbGUiOiJzdHVkZW50IiwidmVyc2lvbiI6IjEuMCIsImF2YXRhcl91cmwiOiJodHRwczovL2ltZy5seWNoZWVyLm5ldC9hdmF0YXIvMWU5YTI5MTA0NzhlYzEyYjMxNWYyZmMzMTIyNTUyNDcvYXZhdGFyIiwidGVsZXBob25lX3ZhbGlkYXRlIjpmYWxzZSwiY2xpZW50X2lwIjoiMzkuMTQ5LjE0LjExMCIsInRva2VuX2tleSI6Ik1DNDROREkzT0RVek1EWTNOakl5TmpNeiIsImlhdCI6MTY2ODAwMjg1OSwiZXhwIjoxNjY4MDI0NDU5fQ.l2qZ3YGGCZ9AcVWRy52dZva66lb3306wBb0MwBodeYI"
r = requests.get(url_xiazai)
print(r)
ls = r.text
string = json.loads(ls)
print(string["data"]["video_info"]["qcloud_video_file_id"])
num = string["data"]["video_info"]["qcloud_video_file_id"]
url_dizhi = "https://apiv1.lizhiweike.com/api/bridge/qcvideo/" + num + "?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiQWNjb3VudFRva2VuIiwiaWQiOjgzMDE5MTEyLCJuaWNrbmFtZSI6IueIseWQg-eLl-mjn-eahOeMq_CfpJNjaXVtIiwic2V4IjoiMSIsInN0YXR1cyI6Im5vcm1hbCIsInN1YnNjcmliZWQiOjAsInJvbGUiOiJzdHVkZW50IiwidmVyc2lvbiI6IjEuMCIsImF2YXRhcl91cmwiOiJodHRwczovL2ltZy5seWNoZWVyLm5ldC9hdmF0YXIvMWU5YTI5MTA0NzhlYzEyYjMxNWYyZmMzMTIyNTUyNDcvYXZhdGFyIiwidGVsZXBob25lX3ZhbGlkYXRlIjpmYWxzZSwiY2xpZW50X2lwIjoiMzkuMTQ5LjE0LjExMCIsInRva2VuX2tleSI6Ik1DNDROREkzT0RVek1EWTNOakl5TmpNeiIsImlhdCI6MTY2ODAwMjg1OSwiZXhwIjoxNjY4MDI0NDU5fQ.l2qZ3YGGCZ9AcVWRy52dZva66lb3306wBb0MwBodeYI"
r_dizhi = requests.get(url_dizhi)
ls_dizhi = r_dizhi.text
str_dizhi = json.loads(ls_dizhi)
print(str_dizhi["data"]["play_url"])
down_file = requests.get(str_dizhi["data"]["play_url"], stream=True)
with open(a[i] + '.mp4', 'wb') as f:
for bl in down_file.iter_content(chunk_size=1024):
if bl:
f.write(bl)
f.close
|