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?
仅有的幸福2017-05-18 10:46:51
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)
我想大声告诉你2017-05-18 10:46:51
Have you tried detecting the increment of the downloaded file?
Check the local size of the downloaded file regularly and take the increment.
曾经蜡笔没有小新2017-05-18 10:46:51
If it is python, most libraries will provide callback functions to do this work.