Created
June 26, 2018 08:38
-
-
Save boozec/3e6a3d60a6d5be2f439cbf12e3f10418 to your computer and use it in GitHub Desktop.
Find Instagram User ID without API
This file contains 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
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