Replies: 1 comment
-
|
you should implement the functions in handle_exception or use any others |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
medias = cl.hashtag_medias_recent('alphabank', amount=500)
I want to see the media on 500 posts, is it possible?
i get this long error:
JSONDecodeError Traceback (most recent call last)
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\public.py in _send_public_request(self, url, data, params, headers, return_json)
129 if return_json:
--> 130 self.last_public_json = response.json()
131 return self.last_public_json
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\requests\models.py in json(self, **kwargs)
909 pass
--> 910 return complexjson.loads(self.text, **kwargs)
911
c:\users\pudge\appdata\local\programs\python\python39\lib\json_init_.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
c:\users\pudge\appdata\local\programs\python\python39\lib\json\decoder.py in decode(self, s, _w)
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
c:\users\pudge\appdata\local\programs\python\python39\lib\json\decoder.py in raw_decode(self, s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
ClientLoginRequired Traceback (most recent call last)
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\hashtag.py in hashtag_medias_recent(self, name, amount)
416 try:
--> 417 medias = self.hashtag_medias_recent_a1(name, amount)
418 except ClientError:
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\hashtag.py in hashtag_medias_recent_a1(self, name, amount)
379 """
--> 380 return self.hashtag_medias_a1(name, amount, tab_key="edge_hashtag_to_media")
381
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\hashtag.py in hashtag_medias_a1(self, name, amount, tab_key)
219 """
--> 220 medias, _ = self.hashtag_medias_a1_chunk(name, amount, tab_key)
221 if amount:
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\hashtag.py in hashtag_medias_a1_chunk(self, name, max_amount, tab_key, end_cursor)
163 while True:
--> 164 data = self.public_a1_request(
165 f"/explore/tags/{name}/",
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\public.py in public_a1_request(self, endpoint, data, params, headers)
172
--> 173 response = self.public_request(
174 url, data=data, params=params, headers=headers, return_json=True
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\public.py in public_request(self, url, data, params, headers, return_json, retries_count, retries_timeout)
73 except (ClientLoginRequired, ClientNotFoundError, ClientBadRequestError) as e:
---> 74 raise e # Stop retries
75 # except JSONDecodeError as e:
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\public.py in public_request(self, url, data, params, headers, return_json, retries_count, retries_timeout)
71 try:
---> 72 return self._send_public_request(url, **kwargs)
73 except (ClientLoginRequired, ClientNotFoundError, ClientBadRequestError) as e:
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\public.py in _send_public_request(self, url, data, params, headers, return_json)
135 if "/login/" in response.url:
--> 136 raise ClientLoginRequired(e, response=response)
137
ClientLoginRequired: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
HTTPError Traceback (most recent call last)
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\private.py in _send_private_request(self, endpoint, data, params, login, with_signature, headers, extra_sig)
297 self.last_response = response
--> 298 response.raise_for_status()
299 # last_json - for Sentry context in traceback
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\requests\models.py in raise_for_status(self)
952 if http_error_msg:
--> 953 raise HTTPError(http_error_msg, response=self)
954
HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/tags/%D0%B0%D0%BB%D1%8C%D1%84%D0%B0%D0%B1%D0%B0%D0%BD%D0%BA/sections/
During handling of the above exception, another exception occurred:
ChallengeRequired Traceback (most recent call last)
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\private.py in private_request(self, endpoint, data, params, login, with_signature, headers, extra_sig)
429 self.private_requests_count += 1
--> 430 self._send_private_request(endpoint, **kwargs)
431 except ClientRequestTimeout:
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\private.py in _send_private_request(self, endpoint, data, params, login, with_signature, headers, extra_sig)
329 if message == "challenge_required":
--> 330 raise ChallengeRequired(**last_json)
331 elif message == "feedback_required":
ChallengeRequired: challenge_required
During handling of the above exception, another exception occurred:
NameError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_10056/3372237980.py in
----> 1 medias = cl.hashtag_medias_recent('альфабанк', amount=500)
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\hashtag.py in hashtag_medias_recent(self, name, amount)
417 medias = self.hashtag_medias_recent_a1(name, amount)
418 except ClientError:
--> 419 medias = self.hashtag_medias_recent_v1(name, amount)
420 return medias
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\hashtag.py in hashtag_medias_recent_v1(self, name, amount)
396 List of objects of Media
397 """
--> 398 return self.hashtag_medias_v1(name, amount, tab_key="recent")
399
400 def hashtag_medias_recent(self, name: str, amount: int = 27) -> List[Media]:
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\hashtag.py in hashtag_medias_v1(self, name, amount, tab_key)
299 List of objects of Media
300 """
--> 301 medias, _ = self.hashtag_medias_v1_chunk(name, amount, tab_key)
302 if amount:
303 medias = medias[:amount]
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\hashtag.py in hashtag_medias_v1_chunk(self, name, max_amount, tab_key, max_id)
256 medias = []
257 while True:
--> 258 result = self.private_request(
259 f"tags/{name}/sections/",
260 params={"max_id": max_id} if max_id else {},
c:\users\pudge\appdata\local\programs\python\python39\lib\site-packages\instagrapi\mixins\private.py in private_request(self, endpoint, data, params, login, with_signature, headers, extra_sig)
437 except Exception as e:
438 if self.handle_exception:
--> 439 self.handle_exception(self, e)
440 elif isinstance(e, ChallengeRequired):
441 self.challenge_resolve(self.last_json)
~\AppData\Local\Temp/ipykernel_10056/3196538109.py in handle_exception(client, e)
21 return self.update_client_settings(client.get_settings())
22 elif isinstance(e, ChallengeRequired):
---> 23 api_path = json_value(client.last_json, "challenge", "api_path")
24 if api_path == "/challenge/":
25 client.set_proxy(self.next_proxy().href)
NameError: name 'json_value' is not defined
Beta Was this translation helpful? Give feedback.
All reactions