如何在没有 API 的情况下获取 Instagram 订阅提要?

How to get Instagram subscriptions feed without API?

我自己写了一个应用程序,它必须在网格中显示我订阅的 feed 照片,因为我没有时间在我的 feed 上刷经典大照片。早些时候我使用了我自己的应用程序,它使用 API,但众所周知,Instagram 关闭了他们的 API 应用程序,这些应用程序处于沙模式。

所以现在我写了一个新的应用程序,它通过 cURL 和 cookies 获取照片(这是我自己的应用程序,所以我使用我自己的 cookies)。

而且我需要的正是我的订阅源,而不是我自己的源。

所以,一开始我只是简单地接收主页的内容(instagram.com)(因为我有 cookie,所以我可以通过访问 Instagram 主页来获取我的 feed)并解析以获取他们的 JSON 原始数据。但问题是我只能以这种方式获得前 24 张照片,但是是否有类似 next_id 或类似的东西可以使用自己的提要,例如?

https://www.instagram.com/instagram/?max_id=1261078189229875262

但最好的方法是立即获取 JSON,无需解析 html,如下所示:

https://www.instagram.com/instagram/media/?max_id=1261078189229875262

非常感谢您的回答。

在 Chrome 中打开您的 Instagram 提要。打开开发工具到网络选项卡。将 Feed 滚动到底部并检查当您将 Feed 滚动到底部时它们发出的 API 调用。

据我所知,他们 post 所有 cookie 以及 2 个参数 $q$refhttps://www.instagram.com/query/

$ref = 'feed::show';
$q = 'ig_me(){feed{media.after(***$end_cursor***,***count***){nodes{id,caption,code,comments.last(4){count,nodes{id,created_at,text,user{id,profile_pic_url,username}},page_info},date,dimensions{height,width},display_src,is_video,likes{count,nodes{user{id,profile_pic_url,username}},viewer_has_liked},location{id,has_public_page,name},owner{id,blocked_by_viewer,followed_by_viewer,full_name,has_blocked_viewer,is_private,profile_pic_url,requested_by_viewer,username},usertags{nodes{user{username},x,y}},video_url,video_views},page_info}},id,profile_pic_url,username}';

在 ig_me() 函数中有一个 $end_cursor 参数。这可以通过检查 window._sharedData 对象的页面找到。

window._sharedData 中,您可以在 entry_data.FeedPage[0].feed.media.page_info.end_cursor

处找到 end_cursor

还有一个 $count 设置为 12 表示返回多少 images/videos (我还没有玩过你可以在这里添加多少)。

此呼叫的响应将在 feed.media.end_cursor 为您提供一个新的 $end_cursor,您可以在下一次呼叫时使用。

祝你好运!