步驟一、在網頁上打開一個視頻,然后復制地址欄的地址
步驟二、在網頁上輸入http://jx.618g.com/?url=步驟一得出的地址
步驟三、待有視頻出來就按F12,在Network中的name找到ts結尾的請求,然后把視頻拉到最后,記錄ts請求的尾數,點擊任意ts請求,找到request_url
步驟四、修改以下程序的base_url、end_index和process_num進行下載
1 """利用多線程,爬取視頻""" 2 import requests 3 from multiprocessing import Pool 4 5 6 def download(base_url, index): 7 headers = { 8 'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'} 9 url = base_url % index 10 res = requests.get(url=url, 11 headers=headers) 12 filename = url.rsplit('/', maxsplit=1)[1] 13 with open(filename, 'wb') as f: 14 f.write(res.content) 15 print('----------------------------------------------------') 16 17 18 if __name__ == '__main__': 19 base_url = 'https://iqiyi.cdn9-okzy.com/20200206/5942_55236082/1000k/hls/fd903296832000%03d.ts' 20 # 記錄影片的最后ts文件數字 21 end_index = 682 22 # 進程個數 23 process_num = 5 24 pool = Pool(process_num) 25 for i in range(end_index + 1): 26 pool.apply_async(download, (base_url, i,)) 27 pool.close() 28 pool.join() 29 print('下載完畢')
步驟五、cmd--->cd 下載目錄--->copy /b *.ts new.mp4
