File Downloading

Fredrik Lundh fredrik at pythonware.com
Wed Aug 14 15:25:55 EDT 2002


Denis S. Otkidach wrote:

> H> I need a script to download a file (any kind of file).
> H> Can you help me?
>
> from shutil import copyfileobj
> from urllib import urlopen
>
> in_fp = urlopen(remote_url)
> out_fp = open(local_file, 'wb')
> copyfileobj(in_fp, out_fp)

or, shorter:

    import urllib

    urllib.urlretrieve(remote_url, local_file)

</F>





More information about the Python-list mailing list