Skip to content

Instantly share code, notes, and snippets.

@aalipar13
Created September 7, 2018 11:26
Show Gist options
  • Save aalipar13/06a823a44f60c5efaa88ffccaf845940 to your computer and use it in GitHub Desktop.
Save aalipar13/06a823a44f60c5efaa88ffccaf845940 to your computer and use it in GitHub Desktop.
import json
import requests
from bs4 import BeautifulSoup
import sys
r = requests.get('https://www.instagram.com/kryzzzie/')
soup = BeautifulSoup(r.text, 'lxml')
script = soup.find('script', text=lambda t: t.startswith('window._sharedData'))
page_json = script.text.split(' = ', 1)[1].rstrip(';')
data = json.loads(page_json)
non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)
for post in data['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges']:
image_src = post['node']['display_url']
print(image_src)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment