Reputation: 61
Trying to do http://support.import.io/knowledgebase/articles/389408-infinite-scroll-without-prerender to scrape instagram photos but can't seem to find the URL.
Anyone know how to do this?
Upvotes: 2
Views: 1637
Reputation: 916
Another way to do it is understand how Instagram handles the infinite scroll. When you hit the bottom of the page, a new request is sent to the server.
This is a POST
request to https://www.instagram.com/query/ passing the following structure as argument:
q:ig_me() {
feed {
media.after(1207458316004284237, 12) {
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
},
page_info
}
},
id,
profile_pic_url,
username
}
ref:feed::show
This piece of data media.after(1207458316004284237, 12)
is actually what tells to the server what to return next and it is the identifier of the last post in the feed. It is basically telling "give me 12 new posts after the post with ID 1207458316004284237"
Upvotes: 3