Skip to content

Instantly share code, notes, and snippets.

@tikseniia
tikseniia / get-location.py
Created February 4, 2019 23:53
Get post location
with open('posts.json', 'r') as f:
arr = json.loads(f.read()) # load json data from previous step
locations = []
for item in arr:
shortcode = item['shortcode']
url = "https://www.instagram.com/p/{0}/?__a=1".format(shortcode)
r = requests.get(url)
data = json.loads(r.text)
try:
@tikseniia
tikseniia / get-posts.py
Created February 4, 2019 23:50
Get Instagram posts for tag
import requests
import time
import json
arr = []
end_cursor = '' # empty for the 1st page
tag = 'russia' # your tag
page_count = 5 # desired number of pages
for i in range(0, page_count):
url = "https://www.instagram.com/explore/tags/{0}/?__a=1&max_id={1}".format(tag, end_cursor)
r = requests.get(url)