alperensert / capmonster_python

Capmonster.cloud library for Python3
https://capmonster-python.quasm.dev/
MIT License
49 stars 11 forks source link

[HELP] #69

Closed Cokeshy closed 6 months ago

Cokeshy commented 6 months ago

i keep getting an error

Error:

Traceback (most recent call last):
  File "c:\Users\Qwerty\Desktop\valo\login.py", line 133, in <module>
    login("a", "a")
  File "c:\Users\Qwerty\Desktop\valo\login.py", line 102, in login
    task_id = capmonster.create_task(website_url=url, website_key=sitekey, custom_data=rqdata)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Qwerty\AppData\Local\Programs\Python\Python312\Lib\site-packages\capmonster_python\hcaptcha.py", line 36, in create_task
    return self._make_request("createTask", data).get("taskId")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Qwerty\AppData\Local\Programs\Python\Python312\Lib\site-packages\capmonster_python\utils.py", line 24, in wrap
    raise CapmonsterException(error_id=rf.get("errorId"),
capmonster_python.utils.CapmonsterException: [ERROR_WRONG_USERAGENT]

Code:

url = f"https://authenticate.riotgames.com{response.headers.get("Location")}"
    response = requests.get(url, headers=headers, cookies=cookies, allow_redirects=False)
    headers = {
        "Accept": "application/json",
        "Accept-Encoding": "gzip, deflate, br",
        "Accept-Language": "en-US,en;q=0.5",
        "Connection": "keep-alive",
        "Content-Type": "application/json",
        "Host": "authenticate.riotgames.com",
        "Referer": url,
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Site": "same-origin",
        "Sec-GPC": "1",
        "TE": "trailers",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0"
    }
    response = requests.get("https://authenticate.riotgames.com/api/v1/login", headers=headers, cookies=cookies, allow_redirects=False).json()
    sitekey = response["captcha"]["hcaptcha"]["key"]
    rqdata = response["captcha"]["hcaptcha"]["data"]
    capmonster = capmonster_python.HCaptchaTask("<>")
    capmonster.set_user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0")
    task_id = capmonster.create_task(website_url=url, website_key=sitekey, custom_data=rqdata)
    result = capmonster.join_task_result(task_id)
alperensert commented 6 months ago

Hello @Cokeshy,

I believe that's not a problem about this package. Also, keep your api key as secret or in an environment file. I suggest you to reset api key of your account.