How do I download a file over HTTP using Python?

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

    If you have wget installed, you can use parallel_sync.

    pip install parallel_sync

    from parallel_sync import wget
    urls = ['http://something.png', 'http://somthing.tar.gz', 'http://somthing.zip']
    wget.download('/tmp', urls)
    # or a single file:
    wget.download('/tmp', urls[0], filenames='x.zip', extract=True)
    

    Doc: https://pythonhosted.org/parallel_sync/pages/examples.html

    This is pretty powerful. It can download files in parallel, retry upon failure , and it can even download files on a remote machine.

提交回复
热议问题