步骤一、在网页上打开一个视频,然后复制地址栏的地址
步骤二、在网页上输入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