Fix Instagram API

master
Nikola Forró 5 years ago
parent 8ba62ec4f6
commit 2b4c1b4c08

@ -1,5 +1,6 @@
import hashlib
import json
import random
import re
from requests_futures.sessions import FuturesSession
@ -17,11 +18,15 @@ class Instagram(object):
try:
graphql = shared_data['entry_data']['ProfilePage'][0]['graphql']
self.user = {k: v for k, v in graphql['user'].items() if not k.startswith('edge')}
self.rhx_gis = shared_data['rhx_gis']
self.rhx_gis = self._get_rhx_gis()
except (IndexError, KeyError, TypeError):
self.user = {}
self.rhx_gis = None
def _get_rhx_gis(self):
s = json.dumps(dict(id=random.randint(10000000, 99999999)))
return hashlib.md5(s.encode('UTF-8')).hexdigest()
def _get_shared_data(self):
session = FuturesSession()
r = session.get('{0}/{1}'.format(BASE_URL, self.username)).result()

Loading…
Cancel
Save