Query Instagram API by tag name to return location

Viewed 480

It was my goal to search Instagram media for a keyword (example "Eiffel Tower") and return results in the form location lat, long.
After researching it seems like there are two ways to do this: using media search but you must provide a location and you are bound to a search radius. I would like a return of lat, longs not confined to a location but rather where ever they occur. Or you can search by tags, which I am not certain this is the same as searching the caption.

Tags in app, is for tagging people. Assuming that search by tag is actually going to return results based off a search term not tagged people. I am getting an error in my script when trying to return lat/longs.

where = raw_input('Where would you like a map of?')
what = raw_input('What would you like to search Instagram for?')
search= api.tag_recent_media(tag_name=what)
map1 = folium.Map(location=geo(where), tiles='Stamen Toner', zoom_start=6)
    if ['location'] is not None:
        for media in search:
            lat_in=(media.location.point.latitude)
            long_in=(media.location.point.longitude)
            print lat_in +", " + long_in
            folium.Marker([lat_in, long_in], popup=content, icon=folium.Icon(icon='info-sign')).add_to(map1)
map1.save('map_instagram.html')  


Traceback (most recent call last):
  File "C:/Users/dana/Desktop/free_instagram.py", line 16, in <module>
    lat_in=(media.location.point.latitude)
AttributeError: 'list' object has no attribute 'location' 

This combination works just fine, using media search but not using tag name/media/recent. Is there a better call I could be making perhaps to Media ID?

0 Answers
Related