← 返回
数据分析 中文

Instagram Scraper

Scrape public Instagram profile data including follower counts, bio, recent posts, and engagement metrics without login or browser. Use when you want to anal...
爬取公开Instagram个人资料数据,包括粉丝数、个人简介、最近帖子和互动数据,无需登录或浏览器。用于分析Instagram账号数据。
phy041
数据分析 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 2
Stars
📥 450
下载
💾 10
安装
1
版本
#instagram#latest#scraping

概述

Instagram Public Profile Scraper

Fetches public Instagram profile data using Instagram's internal API. No login required, no browser needed, no Playwright overhead. Returns structured profile stats and recent post data.

Requirements

pip install httpx

Usage

python instagram_scraper.py <username>
python instagram_scraper.py google
python instagram_scraper.py nike

What It Returns

Profile Data

FieldDescription
--------------------
idInstagram user ID
usernameHandle
full_nameDisplay name
biographyBio text
external_urlLink in bio
is_verifiedBlue check status
is_privateAccount privacy
is_business_accountBusiness profile flag
business_category_nameBusiness category
followers_countFollower count
following_countFollowing count
posts_countTotal post count
profile_pic_urlHD profile photo URL

Recent Posts (up to 12)

FieldDescription
--------------------
idPost ID
shortcodePost shortcode
urlFull post URL
display_urlFull-resolution image
thumbnail_urlThumbnail image
is_videoVideo post flag
captionPost caption text
likes_countLike count
comments_countComment count
timestampUnix timestamp

Output

Results are saved to ./storage/instagram/.json:

{
  "profile": {
    "username": "google",
    "full_name": "Google",
    "followers_count": 12500000,
    ...
  },
  "recent_posts": [
    {
      "url": "https://www.instagram.com/p/ABC123/",
      "likes_count": 45230,
      "caption": "...",
      ...
    }
  ]
}

Implementation

The scraper uses Instagram's internal web API endpoint (i.instagram.com/api/v1/users/web_profile_info/) with a standard browser User-Agent and the public Instagram app ID. This is the same endpoint the Instagram web client calls on first page load.

class InstagramScraper:
    BASE_URL = "https://i.instagram.com/api/v1"
    APP_ID = "936619743392459"  # Public Instagram web app ID

    async def get_profile(self, username: str) -> dict:
        """Fetch a user's public profile data."""
        ...

    def parse_profile(self, raw_data: dict) -> dict:
        """Extract key information from raw profile data."""
        ...

    async def get_recent_posts(self, raw_profile: dict, limit: int = 12) -> list:
        """Extract recent posts from profile data."""
        ...

Error Handling

ErrorCauseFix
-------------------
ValueError: User not foundUsername doesn't exist or is misspelledVerify the handle
PermissionError: Instagram blockedIP rate-limited or flaggedUse a VPN or residential proxy
HTTP 401Request rejectedRotate User-Agent or wait before retrying

Rate Limiting

  • Instagram's internal API is not publicly rate-limited, but aggressive scraping triggers IP blocks.
  • Add a 2-5 second delay between requests when scraping multiple accounts.
  • Private accounts return only public metadata (follower count, bio) but no posts.

Limitations

  • Only works on public profiles
  • Returns up to 12 most recent posts (Instagram's default page size)
  • Does not return Stories, Reels metadata beyond what appears in the timeline grid
  • Video view counts are not included in the internal API response

Use Cases

  • Competitive analysis: track follower growth over time by running daily
  • Influencer vetting: check engagement rate (likes+comments / followers) before partnerships
  • Content research: analyze which post formats drive highest engagement for a niche
  • Brand monitoring: track competitor posting frequency and content themes

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 17:48 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 165 📥 60,076
data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 368 📥 140,565
data-analysis

Data Analysis

ivangdavila
{"answer":"数据分析与可视化。查询数据库、生成报告、自动化电子表格,将原始数据转化为清晰可行的见解。适用于:(1) 您……"}
★ 198 📥 65,156