筆記(B站)
阿新 • • 發佈:2020-11-18
B站視訊下載筆記
import requests headers = { "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0", "accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "accept-encoding":"gzip, deflate, br", "accept-language":"zh-CN,zh;q=0.9", "referer":"https://api.bilibili.com/", "sec-ch-ua-mobile":"?0", "sec-fetch-dest":"document", "sec-fetch-mode":"navigate", "sec-fetch-site":"cross-site", "sec-fetch-user":"?1", "upgrade-insecure-requests":"1", } for i in range(1,2): url="https://cn-gdgz-fx-bcache-07.bilivideo.com/upgcxcode/29/74/247717429/247717429-1-80.flv?e=ig8euxZM2rNcNbujhwdVhoMa7bdVhwdEto8g5X10ugNcXBlqNxHxNEVE5XREto8KqJZHUa6m5J0SqE85tZvEuENvNo8g2ENvNo8i8o859r1qXg8xNEVE5XREto8GuFGv2U7SuxI72X6fTr859r1qXg8gNEVE5XREto8z5JZC2X2gkX5L5F1eTX1jkXlsTXHeux_f2o859IB_\u0026uipk=5\u0026nbs=1\u0026deadline=1605713778\u0026gen=playurl\u0026os=bcache\u0026oi=3401598978\u0026trid=5b3e6f1342494a5e8e0414c06628d8e2u\u0026platform=pc\u0026upsig=ad089d02675aa70791f97493ad6138f5\u0026uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform\u0026cdnid=3807\u0026mid=449154488\u0026orderid=0,3\u0026agrr=0\u0026logo=80000000" #傳送get請求 r = requests.get(url,headers = headers) #變為byte流資料 c = r.content #print(r.text) #儲存視訊 f=open('C:\\Users\\Administrator\\Desktop\\視訊.flv','wb') f.write(c) f.close()