Skip to content

Instantly share code, notes, and snippets.

@nkbt

nkbt/instagram.js

Created Dec 4, 2019
Embed
What would you like to do?
Instagram No-API Public posts access
content = await(await fetch('https://www.instagram.com/nkbtnk/')).text()
doc = new DOMParser().parseFromString(content, 'text/html')
dataEl = Array.from(doc.querySelectorAll('script:not([src])')).find(s => s.innerText.includes('window._sharedData = '))
match = dataEl.innerText.match(/\{.+}/)
data = JSON.parse(match[0])
last12posts = data.entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment