Notice as of today March 2020, Instagram has changed considerably, hence, this question is not similar to previous ones. The issue is that I always get 12 posts instead of all Posts using non Instagram-API ways. I have came across many solutions but all of them only return 12 posts now, even the famous:
https://www.instagram.com/instagram/?__a=1
This is what I get with instagram account that has 6282 posts:
I have also tried the following trick, but it also returns 12 posts:
async function instagramPhotos () {
// It will contain our photos' links
const res = []
try {
const userInfoSource = await Axios.get('https://www.instagram.com/instagram/')
// userInfoSource.data contains the HTML from Axios
const jsonObject = userInfoSource.data.match(/<script type="text\/javascript">window\._sharedData = (.*)<\/script>/)[1].slice(0, -1)
const userInfo = JSON.parse(jsonObject)
// Retrieve only the first 10 results
const mediaArray = userInfo.entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges
for (let media of mediaArray) {
const node = media.node
// Process only if is an image
if ((node.__typename && node.__typename !== 'GraphImage')) {
continue
}
// Push the thumbnail src in the array
res.push(node.thumbnail_src)
}
} catch (e) {
console.error('Unable to retrieve photos. Reason: ' + e.toString())
}
return res
}
There are many npm modules that claim they can get feed without using Instagram API but at the end they only return 12 posts, for example: (instagram-nodejs-without-api)
I run the following code, and I also get only 12 posts:
let Instagram = require('instagram-nodejs-without-api');
Instagram = new Instagram()
const username="instagram"
const password="123hola"
Instagram.getCsrfToken().then((csrf) =>
{
Instagram.csrfToken = csrf;
}).then(() =>
{
return Instagram.auth(username, password).then(sessionId =>
{
Instagram.sessionId = sessionId
return Instagram.getUserDataByUsername(username).then((t) =>
{
console.log(t)
})
})
}).catch(console.error);
My next step is to perform web scraping over Instagram profile but it is very slow specially when images are around 6000, Is there any elegant approach to get these posts? I only want to get my posts so I don't mind to be logged In.
