[Tutor] HTTP file download
Sönmez Kartal
sonmez_programming at nerdshack.com
Wed Mar 14 13:15:41 CET 2007
Hi,
Socket downloads the output of given URL. You can get the file's
extension by URL and save it as a file with it's extension.
Sönmez
Ronaldo wrote:
> 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>
>>
>>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list