forked from DeviatorZ/league-account-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCapMonsterCloud.py
43 lines (37 loc) · 1.51 KB
/
CapMonsterCloud.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import HcaptchaProxylessRequest, HcaptchaRequest
import logging
import asyncio
import config
from typing import Optional, Dict, Any
from captcha.SolvingService import SolvingService
from captcha.constants import CAP_MONSTER_CLOUD
class CapMonsterCloud(SolvingService):
@staticmethod
def solve(apiKey: str, key: str, data: str, userAgent: str, proxy: Optional[Dict[str, Any]] = None) -> Optional[str]:
clientOptions = ClientOptions(api_key=apiKey)
capMonsterClient = CapMonsterClient(options=clientOptions)
requestData = {
"websiteUrl": config.LOGIN_URL,
"websiteKey": key,
"user_agent": userAgent,
"data": data,
}
if proxy is None:
hCaptchaRequest = HcaptchaProxylessRequest(**requestData)
else:
hCaptchaRequest = HcaptchaRequest(
**requestData,
proxy_type=proxy["proxyType"],
proxy_address=proxy["proxyAddress"],
proxy_port=proxy["proxyPort"],
proxy_login=proxy["proxyLogin"],
proxy_password=proxy["proxyPassword"],
)
try:
result = asyncio.run(capMonsterClient.solve_captcha(hCaptchaRequest))
solution = result["gRecaptchaResponse"]
except Exception as e:
logging.error(f"{CAP_MONSTER_CLOUD} Failed: {e}")
return None
return solution