how to time-out gracefully while downloading with python

后端 未结 4 863
面向向阳花
面向向阳花 2021-02-08 11:20

I\'m downloading a huge set of files with following code in a loop:

try:
    urllib.urlretrieve(url2download, destination_on_local_filesystem)
except KeyboardInt         


        
4条回答
  •  醉酒成梦
    2021-02-08 12:02

    There's a discussion of this here. Caveats (in addition to the ones they mention): I haven't tried it, and they're using urllib2, not urllib (would that be a problem for you?) (Actually, now that I think about it, this technique would probably work for urllib, too).

提交回复
热议问题