I used to use urlopen and then read, open a thread, and detect the received buffer size every second. Is there a more elegant way to gain speed?
欢迎选择我的课程,让我们一起见证您的进步~~
For urllib.urlretrieve(url[, filename[, reporthook[, data]]]), write the callback function
import time import urllib start_time = time.time() def Schedule(a,b,c): ''' a:已经下载的数据块 b:数据块的大小 c:远程文件的大小 ''' speed = (a * b) / (time.time() - start_time) print speed urllib.urlretrieve(url,local,Schedule)
Use progreebar
streaming.
Have you tried detecting the increment of the downloaded file? Check the local size of the downloaded file regularly and take the increment.
If it is python, most libraries will provide callback functions to do this work.
For urllib.urlretrieve(url[, filename[, reporthook[, data]]]), write the callback function
Use progreebar
streaming.
Have you tried detecting the increment of the downloaded file?
Check the local size of the downloaded file regularly and take the increment.
If it is python, most libraries will provide callback functions to do this work.