instagram scraper basic profile
The snippet can be accessed without any authentication.
Authored by
Jan Maria Kopankiewicz
from requests import get
from pyquery import PyQuery as pq
import json
import datetime
# Profile as source
# print out all info
profile = "fraunhofer.karriere"
url = 'https://www.instagram.com/'+profile
# dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
try:
doc = pq(get(url).text)
data = (doc('script')[4].text)[21:-1]
jdat = json.loads(data)['entry_data']['ProfilePage'][0]['graphql']['user']
except:
doc = pq(get(url).text)
data = (doc('script')[3].text)[21:-1]
jdat = json.loads(data)['entry_data']['ProfilePage'][0]['graphql']['user']
for key in jdat.keys():
if key == "edge_owner_to_timeline_media":
print("{}\n\n{}\n:".format("###############################",key))
for i in range(0,12):
for media_key in jdat[key]['edges'][i]['node'].keys():
print("{}:\n{}\n".format(media_key,jdat[key]['edges'][i]['node'][media_key]))
print("###############################\n")
if key != "edge_owner_to_timeline_media":
print('{}:\n{}\n'.format(key,jdat[str(key)]))
Please register or sign in to comment