代码可以直接运行。
# -*- coding: utf-8 -*-
from urllibimport request
import os
from multiprocessingimport Pool
from globimport glob
def run(i):
url ="https://hong.tianzhen-zuida.com/20191220/16480_107655d7/1000k/hls/3564346f72c00000"+str(i)+".ts"
print("开始下载:"+url)
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36"}
r = request.Request(url, headers = headers)
# print(r.content)
try:
downloaded_file =open('./mp4/{}'.format(url[-10:]),'wb')
req = request.Request(url, headers={'User-Agent':'Mozilla/5.0'})
file_on_web = request.urlopen(req)
print("downloading...")
while True:
buf = fil