Skip to content

Instantly share code, notes, and snippets.

@GONZOsint
Created September 14, 2022 20:21
Show Gist options
  • Save GONZOsint/42e6977a8e141dbdcaaf5f8632ae55d9 to your computer and use it in GitHub Desktop.
Save GONZOsint/42e6977a8e141dbdcaaf5f8632ae55d9 to your computer and use it in GitHub Desktop.
Script to obtain Instagram user informaption
import requests
import re
import sys
import json
def obtain_ids(user):
response = requests.get('https://www.instagram.com/' + user)
appid = re.search('appId":"(\d*)', response.text)[1]
serverid = re.search('server_revision":(\d*)', response.text)[1]
return appid, serverid
def obtain_user_json(app, server, user):
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) 20100101 Firefox/103.0',
'Accept': '*/*',
'Accept-Language': 'en,en-US;q=0.3',
'X-Instagram-AJAX': server,
'X-IG-App-ID': app,
'X-ASBD-ID': '198337',
'X-IG-WWW-Claim': '0',
'Origin': 'https://www.instagram.com',
'DNT': '1',
'Alt-Used': 'i.instagram.com',
'Connection': 'keep-alive',
'Referer': 'https://www.instagram.com/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'Sec-GPC': '1',
}
params = {
'username': user,
}
response = requests.get('https://i.instagram.com/api/v1/users/web_profile_info/', params=params, headers=headers)
print(json.dumps(response.json(), indent=2))
user = sys.argv[1]
app_id, server_id = obtain_ids(user)
obtain_user_json(app_id, server_id, user)
@instasck
Copy link

king !

@zshanabek
Copy link

zshanabek commented Nov 18, 2024

Thank you

@Sunda001
Copy link

Sunda001 commented Dec 8, 2024

Thank you

does it even work for you?

@instasck
Copy link

instasck commented Dec 8, 2024

Thank you

does it even work for you?

rotate 4g proxy

@Sunda001
Copy link

Sunda001 commented Dec 8, 2024

Thank you

does it even work for you?

rotate 4g proxy

i use residential ip, local ip, i guess it's clean ip because it's not vps

@Vikaskumargd
Copy link

can anyone help me understand why username not working
https://i.instagram.com/api/v1/users/web_profile_info/?username=_.manjari__
happening with lots of username that exist but is not returning any data(it return 200 status)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment