简体   繁体   English

使用python下载文件

[英]File download using python

I am using the mechanize library in python to download some large files from a server. 我在python中使用mechanize库从服务器下载一些大文件。 I need to implement partial file download so that I can parallelize the download of the file. 我需要实现部分文件下载,以便我可以并行化文件的下载。 For that, I added the header "Range: bytes=0-499" to my request. 为此,我在我的请求中添加了标题“Range:bytes = 0-499”。 But the server returns the file starting from the 499th byte. 但是服务器从第499个字节开始返回文件。

The server uses HTTP 1.0. 服务器使用HTTP 1.0。 Is there a way to download the file file partially using python? 有没有办法使用python部分下载文件?

I'm afraid I don't have enough reputation yet to comment so pardon the answer but I believe what you seek is here; 我担心我没有足够的声誉可以发表评论,所以原谅答案,但我相信你所寻求的是在这里;

The Key Differences between HTTP/1.0 and HTTP/1.1 HTTP / 1.0和HTTP / 1.1之间的关键差异

Look under "Bandwidth Optimisation" and "Range Requests" about 25% of the way down the page. 在“带宽优化”和“范围请求”下查看大约25%的页面。

There was no way in HTTP/1.0 to request partial objects. 在HTTP / 1.0中无法请求部分对象。

Whilst some HTTP/1.0 servers have had some HTTP/1.1 features added, I'm afraid this doesn't seem the case on your server. 虽然有些HTTP / 1.0服务器添加了一些HTTP / 1.1功能,但我担心你的服务器上似乎不是这样。

You would be able to tell that it accepted ranges too if the server responded with something like to following: 如果服务器响应以下内容,您将能够告诉它也接受范围:

Accept-Ranges: bytes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM