Python equivalent of a given wget command

前端 未结 10 2203
面向向阳花
面向向阳花 2020-12-02 10:04

I\'m trying to create a Python function that does the same thing as this wget command:

wget -c --read-timeout=5 --tries=0 \"$URL\"

-c

10条回答
  •  情歌与酒
    2020-12-02 11:02

    urllib.request should work. Just set it up in a while(not done) loop, check if a localfile already exists, if it does send a GET with a RANGE header, specifying how far you got in downloading the localfile. Be sure to use read() to append to the localfile until an error occurs.

    This is also potentially a duplicate of Python urllib2 resume download doesn't work when network reconnects

提交回复
热议问题