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

top_search not working #408

Open
5 of 6 tasks
elisamercanti opened this issue Jan 5, 2023 · 0 comments
Open
5 of 6 tasks

top_search not working #408

elisamercanti opened this issue Jan 5, 2023 · 0 comments

Comments

@elisamercanti
Copy link

Please follow the guide below

  • Issues submitted without this template format will be ignored.
  • Please read the questions carefully and answer completely.
  • Do not post screenshots of error messages or code.
  • Put an x into all the boxes [ ] relevant to your issue (==> [x] NO spaces).
  • Use the Preview tab to see how your issue will actually look like.
  • Issues about reverse engineering is out of scope and will be closed without response.
  • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

Before submitting an issue, make sure you have:

  • Updated to the lastest version v1.6.0
  • Read the README and docs
  • Searched the bugtracker for similar issues including closed ones
  • Reviewed the sample code in tests and examples

Which client are you using?

  • app (instagram_private_api/)
  • web (instagram_web_api/)

Describe the Bug/Error:

I'm trying to have a preview of top matching hashtags, users, locations of a certain word and I'm using the dedicated function "top_search". The function gets called properly but a ClientError arises.
I've already checked that email and password are good because they work just fine with other functions like feed_tag.
The code and the error message are pasted below.


Code:

# Example code that will produce the error reported
from instagram_private_api import Client

email, password = MYEMAIL, MYPSW
api = Client(email, password)
resp = api.top_search('farfa')
resp

Error/Debug Log:

Error parsing error response: Expecting value: line 1 column 1 (char 0)
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/instagram_private_api/client.py in _call_api(self, endpoint, params, query, return_response, unsigned, version)
    522             self.logger.debug('DATA: {0!s}'.format(data))
--> 523             response = self.opener.open(req, timeout=self.timeout)
    524         except compat_urllib_error.HTTPError as e:

/usr/lib/python3.8/urllib/request.py in open(self, fullurl, data, timeout)
    530             meth = getattr(processor, meth_name)
--> 531             response = meth(req, response)
    532 

/usr/lib/python3.8/urllib/request.py in http_response(self, request, response)
    639         if not (200 <= code < 300):
--> 640             response = self.parent.error(
    641                 'http', request, response, code, msg, hdrs)

/usr/lib/python3.8/urllib/request.py in error(self, proto, *args)
    568             args = (dict, 'default', 'http_error_default') + orig_args
--> 569             return self._call_chain(*args)
    570 

/usr/lib/python3.8/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
    501             func = getattr(handler, meth_name)
--> 502             result = func(*args)
    503             if result is not None:

/usr/lib/python3.8/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
    648     def http_error_default(self, req, fp, code, msg, hdrs):
--> 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    650 

HTTPError: HTTP Error 404: Not Found

During handling of the above exception, another exception occurred:

ClientError                               Traceback (most recent call last)
<ipython-input-8-6fd8388a332f> in <module>
      1 wordQuery = 'farfa'
      2 
----> 3 resp = api.top_search(wordQuery)
      4 resp

/usr/local/lib/python3.8/dist-packages/instagram_private_api/endpoints/misc.py in top_search(self, query)
    136         :return:
    137         """
--> 138         res = self._call_api(
    139             'fbsearch/topsearch/',
    140             query={'context': 'blended', 'ranked_token': self.rank_token, 'query': query})

/usr/local/lib/python3.8/dist-packages/instagram_private_api/client.py in _call_api(self, endpoint, params, query, return_response, unsigned, version)
    525             error_response = self._read_response(e)
    526             self.logger.debug('RESPONSE: {0:d} {1!s}'.format(e.code, error_response))
--> 527             ErrorHandler.process(e, error_response)
    528 
    529         except (SSLError, timeout, SocketError,

/usr/local/lib/python3.8/dist-packages/instagram_private_api/errors.py in process(http_error, error_response)
    133             logger.warning('Error parsing error response: {}'.format(str(ve)))
    134 
--> 135         raise ClientError(error_msg, http_error.code, error_response)

ClientError: Not Found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant