Skip to content

Instantly share code, notes, and snippets.

@nkbt
Created December 4, 2019 02:53
Show Gist options
  • Save nkbt/f4be5035f618dbe9745906895bc2f6ef to your computer and use it in GitHub Desktop.
Save nkbt/f4be5035f618dbe9745906895bc2f6ef to your computer and use it in GitHub Desktop.
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