我使用python请求为所有人下载ts,但是我失败了,可以帮助您查看我的代码
def download(url, file_name):
print("开始下载 %s" % file_name)
start = datetime.datetime.now().replace(microsecond=0)
try:
response = requests.get(url, stream=True, verify=False)
except Exception as e:
print("异常请求:%s" % e.args)
return
with open(file_name, "wb+") as file:
for chunk in response.iter_content(chunk_size=1024):
if chunk:
file.write(chunk)
end = datetime.datetime.now().replace(microsecond=0)
print("耗时:%s" % (end-start))
这是下载代码,如果我只下载一个.ts。我会成功的。但是,当我为.m3u8下载所有.ts时。我将下载失败。