fetching images from web?
Mike Meyer
mwm at mired.org
Wed Dec 28 00:53:18 EST 2005
randomtalk at gmail.com writes:
> 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)..
Um - what else did you expect? You fetched a gif, you should get a gif.
> 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()
This looks like it works fine to me.
> can someone suggest a better way (or what's wrong with urllib/urllib2)?
> thanks alot!
Can you be more explicit about what you think is wrong with what
you're doing?
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list