How do I download a file over HTTP using Python?

前端 未结 25 3026
感动是毒
感动是毒 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:41

    You can use PycURL on Python 2 and 3.

    import pycurl
    
    FILE_DEST = 'pycurl.html'
    FILE_SRC = 'http://pycurl.io/'
    
    with open(FILE_DEST, 'wb') as f:
        c = pycurl.Curl()
        c.setopt(c.URL, FILE_SRC)
        c.setopt(c.WRITEDATA, f)
        c.perform()
        c.close()
    

提交回复
热议问题