python - 如何在twisted中创建部分下载?

标签 python twisted

如何创建多个异步部分下载的 HTTPDownloader 实例?所有下载完成后它会自动组装文件吗?

最佳答案

您必须使用 Range HTTP header :

Range. Request only part of an entity. Bytes are numbered from 0. Range: bytes=500-999

即。如果您想分 4 部分下载 1000 个文件,您将开始 4 次下载:

  1. 0-2499
  2. 2500-4999
  3. 5000-7499
  4. 7500-9999

然后只需连接响应中的数据即可。

要检查文件大小,您可以使用 HEAD 方法:

HEAD Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content.

关于python - 如何在twisted中创建部分下载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3328059/

相关文章:

python - 为什么 random.sample 比 numpy 的 random.choice 快?

python - 属性错误 : 'str' object has no attribute 'loads' , json.loads()

python - 简单的 dask map_partitions 示例

python - 使用 Twisted 进行非阻塞文件访问

python - 如何使用twisted通过UDP协议(protocol)发送参数

networking - Twisted 中 select/poll 与 epoll react 器的注意事项

python - 检查给定内存地址处的对象

python - 让 python 将带引号的字符串视为一个 block

python - 使用队列以扭曲方式下载文件

python扭曲的多线程服务器