How do I download a file over HTTP using Python?

前端 未结 25 3061
感动是毒
感动是毒 2020-11-21 07:17

I have a small utility that I use to download an MP3 file from a website on a schedule and then builds/updates a podcast XML file which I\'ve added to iTunes.

The te

25条回答
  •  走了就别回头了
    2020-11-21 07:49

    Another way is to call an external process such as curl.exe. Curl by default displays a progress bar, average download speed, time left, and more all formatted neatly in a table. Put curl.exe in the same directory as your script

    from subprocess import call
    url = ""
    call(["curl", {url}, '--output', "song.mp3"])
    

    Note: You cannot specify an output path with curl, so do an os.rename afterwards

提交回复
热议问题