Skip to content

Instantly share code, notes, and snippets.

@onurmatik
Last active November 2, 2017 17:24
Show Gist options
  • Save onurmatik/155934c115b04a782812581b61793ed7 to your computer and use it in GitHub Desktop.
Save onurmatik/155934c115b04a782812581b61793ed7 to your computer and use it in GitHub Desktop.
import re
import json
import requests # pip install requests
profile_pat = re.compile('<script type="text/javascript">window\._sharedData = (.*);</script>')
username = 'onurmatik' # instagram username to check its posts
# The exception handling is excluded for brevity
response = requests.get('https://www.instagram.com/%s/' % username)
match = profile_pat.findall(response.text)
parsed = json.loads(match[0])
shortcodes = [
m['code'] for m in parsed['entry_data']['ProfilePage'][0]['user']['media']['nodes']
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment