You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取指定Instagram公开账号关注的账号用户名?

Hey there! Let's break down your questions about fetching an Instagram public account's following list clearly:

Do I need to use the Instagram API or web scraping?

Both approaches are viable, but they have distinct tradeoffs:

  • Instagram Official API: Meta's Graph API for Instagram is heavily restricted these days. You'd need to apply for developer access (typically reserved for business use cases) and navigate strict rate limits and data access rules. It's overkill if you just want to pull a public account's following list.
  • Web Scraping (or automated client libraries): This is the more practical pick for personal/non-commercial use. Tools that simulate regular user behavior let you access public profile data without dealing with the official API's red tape.

Are special permissions required?

No special developer or elevated permissions are needed, but there's a small caveat:

  • Instagram now requires you to be logged into a regular user account to view the full list of accounts a public profile follows. If you're not logged in, you'll only see a tiny subset of the following entries.
  • You don't need a verified account, business profile, or API keys — just a standard, active Instagram account will suffice.

Is there a simple Python web scraping solution without special permissions?

Absolutely! The instagrapi library is a popular, user-friendly tool that mimics the Instagram app's behavior, and it doesn't require API credentials. Here's a quick, working example:

First, install the library:

pip install instagrapi

Then use this code snippet:

from instagrapi import Client

# Initialize the client
cl = Client()

# Log in with your regular Instagram account credentials
try:
    cl.login("YOUR_INSTAGRAM_USERNAME", "YOUR_INSTAGRAM_PASSWORD")
except Exception as e:
    print(f"Login failed: {e}")
    exit()

# Fetch the following list of the target public account
public_account_username = "PUBLIC_ACCOUNT"
user_id = cl.user_id_from_username(public_account_username)
following = cl.user_following(user_id)

# Extract just the usernames from the response
following_usernames = [user.username for user in following.values()]

# Print the results
print(f"Accounts followed by {public_account_username}:")
for username in following_usernames:
    print("-", username)

# Optional: Log out when finished to keep your account secure
cl.logout()

Key Notes:

  • Don't run this script too frequently or in bulk — Instagram flags unusual activity and may temporarily restrict your account.
  • Ensure you comply with Instagram's Terms of Service; avoid using this for commercial or spammy purposes.
  • If you hit login hurdles (like two-factor authentication), instagrapi supports handling that — check the library's documentation for quick fixes.

内容的提问来源于stack exchange,提问作者HsnVahedi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:33:16