[Tutor] HTTP file download
Ronaldo
ronaldo at netf2r.com
Wed Mar 14 11:56:03 CET 2007
Hi, Jean
I've alredy tried this, but it seems that this kind of code just works
when "file" in the url (http://www.somesite.com/file) is an html file.
The thing is that "file" in this case is a text file. For example: if I
try to download the file using a web browser, it asks me for a directory
to save the file.
Do you have any other idea?
Thanks.
Jean-Philippe Durand wrote:
> Hello Ronaldo,
> Try this :
> import urllib
>
> mysock = urllib.urlopen("http://www.somesite.com/file")
>
> htmlSource = mysock.read()
> mysock.close()
>
> print htmlSource
> Regards.
> Jean-Philippe DURAND
>
>
> 2007/3/13, ronaldo at netf2r.com <mailto:ronaldo at netf2r.com>
> <ronaldo at netf2r.com <mailto:ronaldo at netf2r.com>>:
>
> Hello all,
>
> How can I download a file using HTTP?
> For example:
> There is a file at: http://www.somesite.com/file. I need to get
> this file using HTTP from a python script.
> I'm not sure but I think httplib could be used to do that.
> Can anyone confirm that? or Can anyone suggest me something else?
>
> Thank you?
>
> --
> Ronaldo Z. Afonso
> Phone: 55+11+82619082
> www.netf2r.com <http://www.netf2r.com>
> _______________________________________________
> Tutor maillist - Tutor at python.org <mailto:Tutor at python.org>
> http://mail.python.org/mailman/listinfo/tutor
> <http://mail.python.org/mailman/listinfo/tutor>
>
>
More information about the Tutor
mailing list