Skip to content

Instantly share code, notes, and snippets.

Created October 16, 2020 00:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
[] Instagram'dan foto indirme scripti
import json
import requests
import re
html = requests.get('').text
print('Instagramdan cektigim html boyutu: ', len(html))
pattern = '<script type="text\/javascript">window._sharedData = (.*?);<\/script>'
match_results = re.findall(pattern, html)
match_result = None
if not match_results:
print('HTMLde veri yok muhtemelen private profil.')
match_result = match_results[0]
imgs = []
imgs = json.loads(match_result)['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges']
except Exception as e:
print('Bisiler yanlis gitti', e)
for img in imgs:
img = img['node']
if img['__typename'] == 'GraphImage':
shortcode = img['shortcode']
url = img['display_url']
print('Indirilen post:' + shortcode)
response = requests.get(url)
with open(shortcode + '.png', 'wb') as f:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment