Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing Unable to get rhx_gis from init request (#170) #269

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions instagram_web_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@

# -*- coding: utf-8 -*-

import logging
import gzip
import hashlib
import json
import logging
import random
import re
import gzip
from io import BytesIO
import string
import time
import warnings
from functools import wraps
import string
import random
from io import BytesIO
from socket import timeout, error as SocketError
from ssl import SSLError

from .compat import (
compat_urllib_request, compat_urllib_parse,
compat_urllib_parse_urlparse, compat_urllib_error,
Expand All @@ -29,6 +30,7 @@
ClientConnectionError, ClientBadRequestError,
ClientForbiddenError, ClientThrottledError,
)

try: # Python 3:
# Not a no-op, we're adding this to the namespace so it can be imported.
ConnectionError = ConnectionError # pylint: disable=redefined-builtin
Expand Down Expand Up @@ -309,11 +311,9 @@ def _sanitise_media_id(media_id):

@staticmethod
def _extract_rhx_gis(html):
mobj = re.search(
r'"rhx_gis":"(?P<rhx_gis>[a-f0-9]{32})"', html, re.MULTILINE)
if mobj:
return mobj.group('rhx_gis')
return None
options = string.ascii_lowercase + string.digits
text = ''.join([random.choice(options) for _ in range(8)])
return hashlib.md5(text.encode())

@staticmethod
def _extract_csrftoken(html):
Expand Down