Python equivalent of a given wget command

前端 未结 10 2206
面向向阳花
面向向阳花 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 10:47

    A solution that I often find simpler and more robust is to simply execute a terminal command within python. In your case:

    import os
    url = 'https://www.someurl.com'
    os.system(f"""wget -c --read-timeout=5 --tries=0 "{url}"""")
    

提交回复
热议问题