Hi.
This is my first post, and is about an assignment I've at my college.
An overall description:
We have to make a function, with one argument, the URL. then we have to search the HTML code for any pictures, and to do that I will search for <img and src tags.
All that I can, but then we have to save the pictures local on my harddrive, and make a collage with all the pictures in it. My hindrance right now is the saving part.
For testing the script, I'm using this code:
def getImageUrl(urlstring):
import urllib
connection=urllib.urlopen(urlstring)
picture = connection.read()
connection.close()
curloc = picture.find("img")
if curloc <> -1:
picloc = picture.find("<src", curloc)
picstart = picture.rfind(">",0,picloc)
#writefile.open(picture,"wt")
pic = open(picture, 'wb').read
picture = urllib.urlopen(urlstring)
pic.write(picture)
pic.close()
else:
print "There is no pictures in this URL"
I know my code isn't optimized, but I just can't seem to find the function, so it will save my pictures...
In advanced thanks.
Greetings
Public2