ping / instagram_private_api

A Python library to access Instagram's private API.
MIT License
2.99k stars 619 forks source link

Problem with ajax-request on https://www.instagram.com/graphql/query/?variables #72

Closed Zam4uK closed 6 years ago

Zam4uK commented 6 years ago

Please follow the guide below


Before submitting an issue, make sure you have:

Which client are you using?

Purpose of your issue?


The following sections requests more details for particular types of issues, you can remove any section (the contents between the triple ---) not applicable to your issue.


For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.

Paste the output of python -V here:

The great library!!!But unfortunately some error occurred now

The same issues as was before https://github.com/ping/instagram_private_api/issues/64, when the parser request with ajax error happened. Looks like Instagram blocked request.

from instagram_web_api import Client, ClientCompatPatch, ClientError, ClientLoginError

web_api = Client(auto_patch=True, drop_incompat_keys=False)  

tdm_tag = web_api.tag_feed('python', count=100) 

Error/Debug Log:


HTTPError                                 Traceback (most recent call last)
~/VirtEnv/insta_parser/lib/python3.5/site-packages/instagram_web_api/client.py in _make_request(self, url, params, headers, query, return_response, get_method)
    262             self.logger.debug('REQ DATA: {0!s}'.format(data))
--> 263             res = self.opener.open(req, data=data, timeout=self.timeout)
    264 

/usr/lib/python3.5/urllib/request.py in open(self, fullurl, data, timeout)
    471             meth = getattr(processor, meth_name)
--> 472             response = meth(req, response)
    473 

/usr/lib/python3.5/urllib/request.py in http_response(self, request, response)
    581             response = self.parent.error(
--> 582                 'http', request, response, code, msg, hdrs)
    583 

/usr/lib/python3.5/urllib/request.py in error(self, proto, *args)
    509             args = (dict, 'default', 'http_error_default') + orig_args
--> 510             return self._call_chain(*args)
    511 

/usr/lib/python3.5/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
    443             func = getattr(handler, meth_name)
--> 444             result = func(*args)
    445             if result is not None:

/usr/lib/python3.5/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
    589     def http_error_default(self, req, fp, code, msg, hdrs):
--> 590         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    591 

HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

ClientError                               Traceback (most recent call last)
<ipython-input-16-46f519cb158a> in <module>()
----> 1 tag_feed_info = web_api.tag_feed('python', count=100)

~/VirtEnv/insta_parser/lib/python3.5/site-packages/instagram_web_api/client.py in tag_feed(self, tag, **kwargs)
    807         }
    808 
--> 809         return self._make_request(self.GRAPHQL_API_URL, query=query)
    810 
    811     def location_feed(self, location_id, **kwargs):

~/VirtEnv/insta_parser/lib/python3.5/site-packages/instagram_web_api/client.py in _make_request(self, url, params, headers, query, return_response, get_method)
    278 
    279         except compat_urllib_error.HTTPError as e:
--> 280             raise ClientError('HTTPError "{0!s}" while opening {1!s}'.format(e.reason, url), e.code)
    281         except (SSLError, timeout, SocketError,
    282                 compat_urllib_error.URLError,   # URLError is base of HTTPError

ClientError: HTTPError "Bad Request" while opening https://www.instagram.com/graphql/query/?variables=%7B%22tag_name%22%3A%22python%22%2C%22first%22%3A100%7D&query_hash=ded47faa9a1aaded10161a2ff32abb6b
'''
ping commented 6 years ago

@Zam4uK

Your issue report does not conform to the issue template that has been specified for this repo: https://raw.githubusercontent.com/ping/instagram_private_api/master/.github/ISSUE_TEMPLATE.md

Please edit your issue to comply with the template requirement.

This issue will be closed after 24 hours if no followup action is taken.


[This comment is auto-generated. ref=notemplate]

ping commented 6 years ago

This was already fixed in 18302d94a514df977f468dfb0572850d80c510b3. You can no longer specify any count parameter greater than 50.