Source: http://www.jb51.net/article/42630.htm
urllib Module urlretrieve method
Urllib.urlretrieve (url[, filename[, reporthook[, data]])
Parameter description:
URL: external or local URL
FileName: Specifies the path to be saved locally (if this parameter is not specified, Urllib generates a temporary file to hold the data);
Reporthook: is a callback function that triggers the callback when the server is connected and the corresponding data block is transferred. We can use this callback function to display the current download progress.
Data: Refers to a post to the server. The method returns a tuple of two elements (filename, headers), filename, which represents the local path, and the header represents the server's response header. Example: The following example to illustrate the use of this method, this example of the Sina homepage of the HTML crawl to local, saved in the d:/sina.html file, while showing the progress of the download.
ImportUrllibdefCallbackfunc (Blocknum, BlockSize, totalsize):" "callback function @blocknum: the data block @blocksize: The size of the data block @totalsize: The size of the remote file" "percent= 100.0 * Blocknum * blocksize/totalsizeifPercent > 100: Percent= 100Print "%.2f%%"%Percenturl='http://www.sina.com.cn'Local='d:\\sina.html'urllib.urlretrieve (URL, local, callbackfunc)
"Python" downloads remote content to local