Python uses the urllib2 module to implement resumable download.
This example describes how to use the urllib2 module in Python to implement resumable download. Share it with you for your reference. The specific analysis is as follows:
When using HTTP for download, you only need to set the Range in the header to perform resumable download. Of course, the server must first support resumable download.
Example of resumable download using the Python urllib2 module:
#! /Usr/bin/python #-*-coding: UTF-8-* ''' Created on 2013-04-15 Created by RobinTang A demo for Resuming Transfer ''' import urllib2 req = urllib2.Request ('HTTP: // www.python.org/') req. add_header ('range', 'bytes = 0-20 ') # set the Range, from 0 byte to 19 byte, 20 bytes len res = urllib2.urlopen (req) data = res. read () print data print '--------- 'print 'len: % d' % len (data)
I hope this article will help you with Python programming.