【问题标题】:how get the number follower Instagram with Python如何使用 Python 获取 Instagram 的粉丝数
【发布时间】:2021-07-14 12:37:03
【问题描述】:

我需要使用 python3 查找 Instagram 帐户的关注者数量 我知道 Instagram 改变了政治访问权限。

我尝试下载https://www.instagram.com/user/?__a=1

from bs4 import BeautifulSoup
import requests
import json

# instagram URL
URL = 'https://www.instagram.com/user/?__a=1'

query = "selenium"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36'}
url = 'https://www.google.com?q=' + query
res = requests.get(URL, headers=headers)

response = json.loads(res.text)
print(response)

不过,我找不到追随者的数量。

我在 developers.facebook.com 上创建了一个帐户。我有一个带有 ID 和密码的 API。不过,我看起来不是一个很好的例子。

【问题讨论】:

标签: python instagram-api


【解决方案1】:

您可以尝试使用 python 的facebook-business-sdk 获取 Instagram 帐户信息。 如果您的 IG 帐户是通过 Facebook 连接的,您可以通过以下方式获取信息:

session = FacebookSession(
config['app_id'],
config['app_secret'],
config['access_token'],
)
api = FacebookAdsApi(session)

fb_account = AdAccount("act_***") # Your FB account_id
ig_account = fb_account.get_connected_instagram_accounts(
                        fields=["followers_count"])

您可以找到here的字段列表。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-21
    • 2019-03-09
    • 1970-01-01
    • 1970-01-01
    • 2018-07-31
    • 1970-01-01
    • 2011-04-03
    • 2015-10-12
    相关资源
    最近更新 更多