一段时间后重新开始流的下载/保存

时间:2019-05-11 08:04:44

标签: python

我正在尝试下载流:

 try:
        r = requests.get(url, stream=True)
    except Exception as e:
        print(e)
        time.sleep(100)
        try:
            r = requests.get(url, stream=True)
        except Exception as e:
            print('second request - ', e)

    with open(path, 'wb') as f:
        print(path)
        for chunk in r.iter_content(chunk_size=1024):
            # filter out keep-alive new chunks
            if chunk:
                f.write(chunk)

但是在某些视频上只是“卡住/冻结”,如果未在预定时间内下载,我想进行检查和重置。

0 个答案:

没有答案