Created
September 29, 2015 20:35
-
-
Save hancush/559a047e4a693974ce89 to your computer and use it in GitHub Desktop.
pulls location ids from within 5000m of bangkok city center, counts photos posted to each within last 24 hours, finds nothinggggggggg (dunno why)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from instagram.client import InstagramAPI | |
import httplib2 | |
import simplejson | |
import six | |
api = InstagramAPI( | |
client_id='adeb7a8be4d0463b8bae5e12df37145e', | |
client_secret='428e9e381d3e4a9298a307fd322aaf24', | |
access_token='181028960.adeb7a8.43b0ef71f8df44cda7e75c6e10740672' | |
) | |
find_locations = api.location_search( | |
count=200, | |
lat='13.7246005', | |
lng='100.6331108', | |
distance=5000 | |
) | |
locations = [] | |
for result in find_locations: | |
location, id_, point, lat, long_ = str(result).split() | |
locations.append(int(id_)) | |
day_count = 0 | |
def count(place): | |
recent_media, next = api.location_recent_media( | |
location_id=place, | |
min_timestamp=1443454200 | |
) | |
while next: | |
more_media, next = api.location_recent_media( | |
location_id=place, | |
min_timestamp=1443454200, | |
with_next_url=next | |
) | |
for post in recent_media: | |
global day_count | |
day_count += 1 | |
print "Found {0} photos so far...".format(day_count) | |
for place in locations: | |
print "Searching {0}!".format(place) | |
count(place) | |
week_count = day_count * 7 | |
print "{0} photos total found in the last 24 hours. That's {1} in a week.".format( | |
day_count, | |
week_count | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment