更新时间:2023-11-19 14:53:52
带有query_hash
="58712303d941c6855d4e888c5f0cd22f"(以下)和"37479f2b8209594dde7facb0d904896a"(跟随者)的GraphQL查询返回此信息.登录后,使用参数query_hash
和variables
对instagram.com/graphql/query进行GET查询,其中variables
是一组JSON格式的变量id
(用户ID,如返回get_user_info()
函数的字典),first
(一个页面长度,似乎当前最大值为50),并且在后续请求中,after
在上一个响应字典中设置为end_cursor
.
GraphQL queries with query_hash
= "58712303d941c6855d4e888c5f0cd22f" (followings) and "37479f2b8209594dde7facb0d904896a" (followers) return this information. With being logged in, do a GET query to instagram.com/graphql/query with parameters query_hash
and variables
, where variables
is a JSON-formatted set of variables id
(user id, as in the return dictionary of your get_user_info()
function), first
(a page length, it seems the current maximum is 50) and in subsequent requests after
set to the end_cursor
in the previous response dictionary.
或者, Instaloader 库提供了一种方便的登录方式,然后以编程方式访问配置文件的关注者和关注者列表
Alternatively, the Instaloader library provides a convenient way to login and then programmatically access a profile's followers and followings list.
import instaloader
# Get instance
L = instaloader.Instaloader()
# Login or load session
L.login(USER, PASSWORD) # (login)
L.interactive_login(USER) # (ask password on terminal)
L.load_session_from_file(USER) # (load session created w/
# `instaloader -l USERNAME`)
# Obtain profile metadata
profile = instaloader.Profile.from_username(L.context, PROFILE)
# Print list of followees
for followee in profile.get_followees():
print(followee.username)
# (likewise with profile.get_followers())
除了username
之外,在为每个跟随者返回的Profile
实例中定义了full_name
,userid
,followed_by_viewer
等属性.
Besides username
, the attributes full_name
, userid
, followed_by_viewer
and many more are defined in the Profile
instance that is returned for each followee.