Skip to content

Instantly share code, notes, and snippets.

@boozec
Created June 26, 2018 08:38
Show Gist options
  • Save boozec/3e6a3d60a6d5be2f439cbf12e3f10418 to your computer and use it in GitHub Desktop.
Save boozec/3e6a3d60a6d5be2f439cbf12e3f10418 to your computer and use it in GitHub Desktop.
Find Instagram User ID without API
import urllib.request
from bs4 import BeautifulSoup as bs4
import re
import sys
p = urllib.request.urlopen(urllib.request.Request('https://www.instagram.com/%s/' % sys.argv[1]))
bs = bs4(p, 'html.parser')
data = bs.findAll("script")[3]
pattern = re.search(r'\"id":"(\d+)"', data.text)
print(pattern.group()[6:-1])
# python3 userid.py sa_cariotti
# > 1333088338
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment