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

cloudscraper CloudflareChallengeError #35

Open
famdude opened this issue May 22, 2024 · 1 comment
Open

cloudscraper CloudflareChallengeError #35

famdude opened this issue May 22, 2024 · 1 comment

Comments

@famdude
Copy link

famdude commented May 22, 2024

I got this error when tried to get free daily book, so I changed api_request and api_request_web to print session and response:

def api_request(base_url: str, endpoint: str, params=None, **kwargs):
    """
    Wrapper for verifying and retrying GET requests to the Blinkist API.
    Returns the parsed JSON response.
    Calls `request` internally.
    """
    url = base_url + endpoint
    response = request(url, params=params, headers=HEADERS, **kwargs)
    print("RSPONSE")
    print(response)
    return response.json()


def api_request_web(endpoint: str, params=None):
    """
    Wrapper for verifying and retrying GET requests to the Blinkist web API (https://blinkist.com/api/).
    Returns the parsed JSON response.
    """
    print("SESSION COOKOES")
    print(session_cookies)
    return api_request(
        "https://blinkist.com/api/", endpoint, params=params, cookies=session_cookies
    )

but still getting same error. here's the output I get:

SESSION COOKOES
None
⠋ Retrieving free daily in en…[11:56:42] INFO     Retrying in 2.0 seconds…                                                                                  common.py:26
⠼ Retrieving free daily in en…[11:56:46] INFO     Retrying in 2.0 seconds…                                                                                  common.py:26
Traceback (most recent call last):
  File "/path/to/package/blinkist/.venv/lib/python3.10/site-packages/tenacity/__init__.py", line 382, in __call__
    result = fn(*args, **kwargs)
  File "/path/to/package/blinkist/blinkist/common.py", line 41, in request
    raise cloudscraper.exceptions.CloudflareChallengeError()
cloudscraper.exceptions.CloudflareChallengeError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/path/to/package/blinkist/./main.py", line 200, in <module>
    main()
  File "/path/to/package/blinkist/.venv/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/path/to/package/blinkist/.venv/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/path/to/package/blinkist/.venv/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/path/to/package/blinkist/.venv/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/path/to/package/blinkist/./main.py", line 150, in main
    book = get_free_daily(locale=language_)
  File "/path/to/package/blinkist/blinkist/blinkist.py", line 18, in get_free_daily
    free_daily = api_request_web('free_daily', params={'locale': locale})
  File "/path/to/package/blinkist/blinkist/common.py", line 67, in api_request_web
    return api_request(
  File "/path/to/package/blinkist/blinkist/common.py", line 54, in api_request
    response = request(url, params=params, headers=HEADERS, **kwargs)
  File "/path/to/package/blinkist/.venv/lib/python3.10/site-packages/tenacity/__init__.py", line 289, in wrapped_f
    return self(f, *args, **kw)
  File "/path/to/package/blinkist/.venv/lib/python3.10/site-packages/tenacity/__init__.py", line 379, in __call__
    do = self.iter(retry_state=retry_state)
  File "/path/to/package/blinkist/.venv/lib/python3.10/site-packages/tenacity/__init__.py", line 326, in iter
    raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x76af9d056680 state=finished raised CloudflareChallengeError>]
@hongthaiphi
Copy link

I have same error:
tenacity.RetryError: RetryError[<Future at 0x16f6783b910 state=finished raised CloudflareChallengeError>]

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

2 participants