json 如何在没有令牌或访问控制的情况下从userId(pk)获取instagram用户配置文件详细信息?

ipakzgxi  于 2023-06-25  发布在  其他
关注(0)|答案(3)|浏览(103)

今天Instagram本身通过使用下面的URL给用户详细信息,但现在它不起作用。

https://i.instagram.com/api/v1/users/{userID}/info/

先谢谢你了

q3qa4bjr

q3qa4bjr1#

同样的问题
从Instagram注销,然后重定向到:

https://www.instagram.com/accounts/login/?next=/api/v1/users/{userID}/info/
yb3bgrhw

yb3bgrhw2#

使用python库**“ensta”**。

用法

  • Guest 模式不需要登录。
  • Host 模式支持通过Instagram会话ID登录。

安装

pip install ensta

示例

为了您的目的,您可以使用此功能:

from ensta import Guest

guest = Guest()

username = guest.get_username("user_id"). # UserID to Username
info = guest.profile_info(username)
print(info)
uyto3xhc

uyto3xhc3#

python您需要User-Agent和登录会话

headers = {
        'User-Agent': 'Instagram 27.0.0.7.97 (iPhone7,2; iPhone OS 9_3_3; en_US; en-US; scale=2.00; 750x1334) AppleWebKit/420+'}
session = requests.Session()
"login stuff here"
response = session.get(url, headers=headers)

测试和工作

相关问题