urlretrieve get file name

Sven sven.dahlstrand at gmail.com
Thu Nov 9 18:52:39 EST 2006


Hello Gabriel,

Thanks for your help, but I'm a guy with no luck. :-) I can't get the
file name from response header...

On Nov 10, 12:39 am, Gabriel Genellina <gagsl... at yahoo.com.ar> wrote:
> At Thursday 9/11/2006 19:11, Sven wrote:
>
> >I'm wrestling with the urlretrieve function in the urllib module. I
> >want to download a file from a web server and save it locally with the
> >same name. The problem is the URL - it's on the form
> >http://www.page.com/?download=12345. It doesn't reveal the file name.
> >Some hints to point me in the right direction are greatly appreciated.The file name *may* come in the Content-Disposition header (ex:
> Content-Disposition: attachment; filename="budget.xls")
> Use urlopen to obtain a file-like object; its info() method gives you
> those headers.
>
> --
> Gabriel Genellina
> Softlab SRL
>
> __________________________________________________
> Correo Yahoo!
> Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
> ¡Abrí tu cuenta ya! -http://correo.yahoo.com.ar




More information about the Python-list mailing list