Instagram Profile Data Extractor
By asermnasr
AGENTSocial Media
descriptionDescription
Extracts public profile details from Instagram including bio, follower counts, following counts, and post statistics using a specific username.
data_objectVariables
usernamestring
humansofny
settingsBehavior & Action Config
Wait Time (ms)1
Rotate UAfalse
Rotate Proxiesfalse
Rotate Viewportfalse
Human Typingfalse
Shadow DOMtrue
Disable Recordingfalse
Stateless Execfalse
Stealth Features
fatigue
allowTypos
deadClicks
overscroll
idleMovements
naturalTyping
account_treeAutomation Steps
1
click
div[role="dialog"] div[role="button"]outputExpected Output
| username | name | bio | profilePicUrl | posts | followers | following |
|---|---|---|---|---|---|---|
humansofny | Humans of New York | New York City, one story at a time. Created by Brandon Stanton. Dear New York now available wherever books are sold... more | https://scontent-lga3-3.cdninstagram.com/v/t51.2885-19/488057622_654626203990134_4938995104135839433_n.jpg?stp=dst-jpg_s150x150_tt6&efg=eyJ2ZW5jb2RlX3RhZyI6InByb2ZpbGVfcGljLmRqYW5nby4xMDAwLmMyIn0&_nc_ht=scontent-lga3-3.cdninstagram.com&_nc_cat=106&_nc_oc=Q6cZ2QF-MIvWhx0_SepseqpB3xU7cv8S3Gz-mWd_yQK18AOTru2XGj6pQXUvdS8_4kYdk30&_nc_ohc=cWzOlEZ2-Y8Q7kNvwFmWIzi&_nc_gid=A9ZHmnBZkbczIgNyJ862fw&edm=AOQ1c0wBAAAA&ccb=7-5&oh=00_Aftsy1o7FllY9vUug_BBy8VMHNc3d8A7-0r2DQI0x8f5UA&oe=69A001C1&_nc_sid=8b3546 | 5,844 | 12,762,580 | 697 |
codeExtraction Script
// 1. Access the raw HTML
const rawHtml = $$data.html();
// 2. Parse the string
const parser = new DOMParser();
const doc = parser.parseFromString(rawHtml, 'text/html');
// Improved helper: uses textContent and optional chaining for safety
const scrubText = (selector, root = doc) => {
return root.querySelector(selector)?.textContent?.trim() || null;
};
const getStat = (index) => {
const listItems = doc.querySelectorAll('header ul li');
const li = listItems[index];
if (!li) return "0";
// Instagram often stores full numbers in the 'title' attribute
const titleVal = li.querySelector('span[title]')?.getAttribute('title');
if (titleVal) return titleVal.trim();
// Fallback to the nested span textContent
return li.querySelector('span span')?.textContent?.trim() || "0";
};
// 3. Extract data from the parsed document
const profileData = {
username: scrubText('h2'), //
name: scrubText('header section > div:nth-of-type(2) span:first-child'), //
bio: scrubText('.xmaf8s6'), //
profilePicUrl: doc.querySelector('header img')?.getAttribute('src') || null, //
posts: getStat(0), //
followers: getStat(1), //
following: getStat(2) //
};
return profileData;