84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
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.