此脚本会在日期之间打印包含特定标记的所有地理定位Instagram照片的CSV。直接从这里检索... https://gist.github.com/mapmeld/4161980。我知道Instagram api最近有一些变化。这个错误意味着什么,我该如何解决?
import json
import urllib
import datetime
createdate = datetime.datetime.now()
latestprint = datetime.datetime(2012, 11, 11) # Nov 11, 2012
earliestprint = datetime.datetime(2012, 10, 28) # Oct 28, 2012
client_id = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
client_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
access_token="XXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXX"
max_id = ""
tagname = "wtamu"
csvout = open('wtamu.csv', 'w')
print "ID, CREATED_TIME, LATITUDE, LONGITUDE, INSTAGRAM URL, PHOTO URL"
csvout.write("ID,CREATED_TIME,LATITUDE,LONGITUDE,INSTAGRAM_URL,PHOTO_URL\n")
while(createdate > earliestprint):
apiout = urllib.urlopen("https://api.instagram.com/v1/tags/" + tagname + "/media/recent?max_id=" + max_id + "&access_token=" + access_token).read()
photopage = None
try:
photopage = json.loads( apiout )
except:
print apiout
continue
photos = photopage["data"]
for photo in photos:
createdate = datetime.datetime.fromtimestamp(int(photo["created_time"]) )
#print createdate
if(createdate < latestprint and createdate > earliestprint):
# inside timestamp bounds
if((photo.has_key("location") == True) and (photo["location"] is not None) and (photo["location"].has_key("latitude") == True)):
# has a location
latitude = str(photo["location"]["latitude"])
longitude = str(photo["location"]["longitude"])
# print out CSV format
print "\"" + (photo["id"] or "") + "\"," + (photo["created_time"] or "") + "000," + latitude + "," + longitude + ",\"" + (photo["link"] or "") + "\",\"" + (photo["images"]["standard_resolution"]["url"] or "") + "\""
csvout.write("\"" + (photo["id"] or "") + "\"," + (photo["created_time"] or "") + "000," + latitude + "," + longitude + ",\"" + (photo["link"] or "") + "\",\"" + (photo["images"]["standard_resolution"]["url"] or "") + "\"\n")
max_id = photopage["pagination"]["next_max_id"]
print "max_id = " + max_id
createdate = datetime.datetime.fromtimestamp( int( int( max_id ) / 1000 ) )