if use 0 instead of x ( in while loop) program works , 1st photo someone's favorite list flickr if want more or other 1st photo error
import flickrlib import webbrowser flickr_api_key = "f86203e922041a6a999fd4a59f19b1e6" flickr_api_ssecret = "b286bcaddafb00c8" flickruser = raw_input("who interested in? ") amount = int(raw_input("how many pictures see? ")) total = amount counter = 0 imagepile = "" x= 0 client = flickrlib.flickragent(flickr_api_key, flickr_api_ssecret) person = client.flickr.people.findbyusername( username= flickruser) userid = person[u'id'] photos = client.flickr.favorites.getpubliclist(user_id= userid, per_page=1) while counter < total: farm = photos[u'photo'] [x] [u'farm'] server = photos[u'photo'] [x] [u'server'] photo_id = photos[u'photo'] [x] [u'id'] secret = photos[u'photo'] [x] [u'secret'] imgsrc = "<img src='http://farm" + farm + ".static.flickr.com/" + server + "/" + photo_id + "_" + secret +".jpg' /><br />" imagepile = imagepile + imgsrc counter= counter+1 x=x+1 htmlopen = "<html><head><title>"+ flickruser + "</title></head><body><h1>" + flickruser + "'s public list. ""</h1>" simple_page = htmlopen + imagepile + "</body></html>" xml_file = open("webpage.html", "w") xml_file.write(simple_page) xml_file.close() webbrowser.open("webpage.html")
i don't know flickr's api, looks you're asking 1 photo in getpubliclist
. either way, you're not checking make sure total
less number of pictures returned getpubliclist
.
Comments
Post a Comment