Python2使用服务器站点压缩下载二进制文件

时间:2017-03-02 07:41:27

标签: python python-2.7 http compression

通过Stackoverflow搜索我发现了很多答案如何用Python下载文件(可能是使用urllib2,请求等),但只有one用于使用压缩(httplib2)。可悲的是,这个答案不是使用流。

如何使用压缩和流下载Python的大型二进制文件?

我目前使用的是放慢速度并查看以下内容:

def get_large_file_a(url, file, length): # using requests

    response = requests.get(url, stream=True)

    with open(file, 'wb') as f:
        for data in tqdm(
                response.iter_content(),
                total=length,
                unit='B',
                unit_scale=True,
        ):
            f.write(data)

0 个答案:

没有答案