如何使用 Instagram graphql?

Val*_*dir 5 instagram graphql

我正在使用以下查询 https://www.instagram.com/graphql/query/?query_id=17851374694183129&id={acountId}&first=1000&after={cursor} 来获取用户关注者。我需要的信息是followed_by_count每个用户都可以使用的索引https://www.instagram.com/{username}?__a=1

结果中是否query_id包含followed_by_count

Mar*_*ark 5

query_id代码https://www.instagram.com/graphql/query/?query_id=17851374694183129&id=<user_id>&first=1000&after=<end_cursor>旨在仅返回不包括用户配置文件数据的媒体数据。

最简单的解决方案是使用 IG 在初始页面请求上使用的内容:

https://www.instagram.com/<ig_username>/?__a=1

这是我的 RubyOnRails 设置:

profile = JSON.parse(open("https://www.instagram.com/<ig_username>/?__a=1").read)

...现在抓住你的变量:

profile.['graphql']['user']['profile_pic_url']
 
profile.['graphql']['user']['biography']

profile.['graphql']['user']['external_url']

profile.['graphql']['user']['edge_followed_by']['count']

profile.['graphql']['user']['edge_follow']['count']

profile.['graphql']['user']['id']

profile.['graphql']['user']['edge_owner_to_timeline_media']['count']

profile.['graphql']['user']['profile_pic_url']

profile.['graphql']['user']['profile_pic_url_hd']
Run Code Online (Sandbox Code Playgroud)

而你followed_by_count现在['graphql']['user']['edge_followed_by']['count']

  • @Ollie 不幸的是,这也已被弃用。目前没有通过公共 json 请求访问公共数据的简单方法。 (2认同)