Instagram is a visually-focused social media platform where users can share photos, videos, live streams, and Stories. As a global social network with millions of users, it offers valuable data for businesses. Scraping personal profile data can provide insightful information about popular users worldwide, helping to predict future trends and identify potential new audiences.
How to Scrape Profile Data?
We can use a Python-based Instagram profile scraping tool.
First, locate the target URL, such as https://www.instagram.com/target_username/. Press F12 to open Developer Tools and inspect the page source to find the relevant JSON data. User information is nested within the <script> tag containing window._sharedData. Parse this data accordingly.

Next, install the necessary Python libraries and set up the request headers. Use a User-Agent and Referer header to avoid being detected by anti-scraping mechanisms.
pip install fake-useragent
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
"Referer": "https://www.instagram.com/"
}
Finally, parse the JSON data from the webpage, convert it into a Python dictionary, and extract the needed information—such as username, bio, number of posts, etc.—then save the results.
Simple Example:
Python
import requests
import json
def get_insta_profile(username):
# Construct with special parameters API URL
url = f"https://www.instagram.com/{username}/?__a=1&__d=dis"
# Use a common browser User-Agent
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"}
try:
# Send the request and directly parse the JSON
response = requests.get(url, headers=headers, timeout=8)
response.raise_for_status()
user_data = response.json().get("graphql", {}).get("user", {})
if not user_data:
print(f"❌ Unable to find data for user '{username}'.。")
return
# Extract and print core information
profile = {
"username": user_data.get("username"),
"fullName": user_data.get("full_name"),
"followers": user_data.get("edge_followed_by", {}).get("count"),
"following": user_data.get("edge_follow", {}).get("count"),
"posts": user_data.get("edge_owner_to_timeline_media", {}).get("count"),
"isVerified": user_data.get("is_verified"),
"profilePicUrl": user_data.get("profile_pic_url_hd")
}
print(json.dumps(profile, indent=2))
except requests.exceptions.RequestException as e:
print(f"❌ Request failed: {e}")
except json.JSONDecodeError:
print("❌ Failed to parse JSON, it may have been intercepted.。")
# --- Main program ---
if __name__ == "__main__":
# Enter the username of the foreign public figure you want to capture here.
target_username = "nasa"
get_insta_profile(target_username)