[Tutor] need help with urllib

Magnus Lycka magnus@thinkware.se
Sat, 05 Oct 2002 23:45:52 +0200


At 12:43 2002-10-05 -0400, Jmllr891@cs.com wrote:
>I've recently been trying to write a script that will download images off 
>the web for me (say a daily comic strip or something of that sort).
>
>The script works perfectly fine, it downloads the image and produces no 
>errors. But the image is always corrupt or something. No matter what I try 
>to view it in (even a web browser) it can't be displayed.

Did you try renaming it to something.txt before opening it?

>This is my code (this one downloads the Python logo):

No, it doesn't. ;)

>import urllib
>
>image = URLopener()
>image.retrieve('http://www.python.org/pics/', 'pythonHi.gif')

Read The Fine Manual: URLopener.retrieve(url[,filename[...]])
Retrieves the content of url (a directory listing, or error
message in this case) and places it in file name.


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se