How do I get the next page of data from a instagram tag look up
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Magical Minnie Puzzles
--
Chapters
00:00 How Do I Get The Next Page Of Data From A Instagram Tag Look Up
00:56 Accepted Answer Score 7
01:40 Answer 2 Score 2
04:03 Answer 3 Score 2
04:35 Thank you
--
Full question
https://stackoverflow.com/questions/4849...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pythonrequests #instagram #instagramapi
#avk47
ACCEPTED ANSWER
Score 7
This is possible. Each response includes an end_cursor parameter. In your next request add a max_id parameter using the value of end_cursor, like so: https://www.instagram.com/explore/tags/losangeles/?__a=1&max_id=<value>. 
I have a working example here written in react/axios: https://codepen.io/ghostreef/pen/ZrKrXX. My example pulls from a user account, so my response xml is different. The end_cursor for tags is at data.graphql.hashtag.edge_hashtag_to_media.page_info.end_cursor and the image data is at data.graphql.hashtag.edge_hashtag_to_media.edges and you'll have to iterate over the nodes.
ANSWER 2
Score 2
Well I've just read this article and applied the same procedure on the tag page and you can definitely do this on any other page you would like.
You can inspect every request (and also JavaScripts) on the browser to find where query_hash and afterparameters come from. 
What is the requested URL when we load more content?
First of all, let's take a look at what is the requested URL when we load more content. You can simply do this by going to https://instagram.com/explore/tags/ruby and then scroll down until it loads another chunk of images while inspecting.
You will see a GET request to below URL:
What do we need to know to get the next page?
Well as you see above in the link we need:
query_hashafter
I couldn't really figure out how first parameter works but it loads more content if you put a greater value but not exactly the same number of content.
Where do we get variables after and query_hash?
So far so good. If we know the query_hash and after variables we can request the next page of the images. 
You can easily get to a tag page's first JSON file by the help of this link:
https://www.instagram.com/explore/tags/yourtagname/?__a=1
I've used ruby tag so mine would be:
https://www.instagram.com/explore/tags/ruby/?__a=1
After loading the JSON file you can see there is a variable called end_cursor. This is our after parameter.
To get your query_hash parameter you will need to take a look at the .js file 
https://www.instagram.com/static/bundles/base/TagPageContainer.js/f1172b0dfea6.js
Then there you just need to search for the string byTagName.get(t).pagination},queryId:" which is followed by the query_hash you will need.
Then just put all the pieces together using the variables we've found above and browse to our new link to get the JSON file of the next page like so.
ANSWER 3
Score 2
April 2021 update - Yesterday, Instagram changed the response with tags lookup. As a result, if you look for a specific tag, the response will not contain an "end_cursor" anymore. Instead, you should look for an element called "next_max_id" (located at the very bottom of the response you get from Instagram). The value is similar: eg: QVFBUTVDc2xKMnRKSVZseVdFNk5wR05zRkt4ODhUUWg2dzU2VlVhMUxGZ2xobVc4V01Jby1TM1pRRmFaWUIxRmJkUmdDSjVOc24wVDlOc0NiQTB2Z3U3Vg==
