fetching images from web?

R

randomtalk

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:


can someone suggest a better way (or what's wrong with urllib/urllib2)?
thanks alot!
 
M

Mike Meyer

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:

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
 
A

Alex Martelli

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:

Since you appear to want to write binary data, you should use 'wb', not
'w', as the "mode".


Alex
 
A

annaiak

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:





can someone suggest a better way (or what's wrong with urllib/urllib2)?
thanks alot!
fetching images from web is my little hobby (but i dont know, if you
want fetch this kind of images). i sending my little script.

import urllib
for i in range(25,286,1):
if i<100: n='0'+str(i)
else: n=str(i)
for j in range(16):
if j<10: o='0'+str(j)
else: o=str(j)
s='used for error detecting'
url='http://www.paradisetoons.com/ima/toon'+str(i)+'/p'+str(j)+'.jpg'
fil='e:/pics/xxz37/prtn_'+n+'_'+o+'.jpg'
try:
s=urllib.urlopen(url).readline(6)
except:
print ''
if s.lower()=='<html>':
print 'file '+url+' does not exist'
else:
print 'downloading file: '+url
urllib.urlretrieve(url,fil)

any sugestions for doing this better?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top