fetching images from web?

bonono at gmail.com bonono at gmail.com
Wed Dec 28 01:03:53 EST 2005


may be using wget/curl but then it is no longer python ;-)

randomtalk at gmail.com wrote:
> hi, i want to automate some tasks of gathering photos from web, i tried
> urllib/urllib2, both ended up without much success (saved gifs with
> only a border, nothing else)..
>
> the code i used was:
>
> >>> data = urllib2.urlopen("http://aspn.activestate.com/ASPN/img/komodo_aspn_other.gif")  #was looking through cookbook, so i used that as a sample image
> >>> data = data.read()
> >>> file = open("f:/test.gif", "w")
> >>> file.write(data)
> >>> file.close()
>
>
> can someone suggest a better way (or what's wrong with urllib/urllib2)?
> thanks alot!




More information about the Python-list mailing list