Commit ca5539ef authored by Florian Duguet's avatar Florian Duguet Committed by ntome

[anticaptcha] manage Recaptcha v3

parent c4368e54
......@@ -24,7 +24,7 @@ from base64 import b64encode
from weboob.browser.browsers import APIBrowser
from weboob.exceptions import BrowserIncorrectPassword, BrowserBanned
from weboob.capabilities.captcha import (
ImageCaptchaJob, RecaptchaJob, NocaptchaJob, FuncaptchaJob, CaptchaError,
ImageCaptchaJob, RecaptchaJob, RecaptchaV3Job, NocaptchaJob, FuncaptchaJob, CaptchaError,
InsufficientFunds, UnsolvableCaptcha, InvalidCaptcha,
)
......@@ -74,6 +74,20 @@ class AnticaptchaBrowser(APIBrowser):
r = self.request('/createTask', data=data)
return str(r['taskId'])
def post_gcaptchav3(self, url, key, action):
data = {
"clientKey": self.apikey,
"task":{
"type":"RecaptchaV3TaskProxyless",
"websiteURL": url,
"websiteKey": key,
"minScore": 0.3,
"pageAction": action
}
}
r = self.request('/createTask', data=data)
return str(r['taskId'])
def post_funcaptcha(self, url, key, sub_domain):
data = {
"clientKey": self.apikey,
......@@ -128,7 +142,7 @@ class AnticaptchaBrowser(APIBrowser):
elif isinstance(job, RecaptchaJob):
job.solution = sol['recaptchaResponse']
job.solution_challenge = sol['recaptchaChallenge']
elif isinstance(job, NocaptchaJob):
elif isinstance(job, NocaptchaJob) or isinstance(job, RecaptchaV3Job):
job.solution = sol['gRecaptchaResponse']
elif isinstance(job, FuncaptchaJob):
job.solution = sol['token']
......
......@@ -21,7 +21,9 @@ from __future__ import unicode_literals
from weboob.tools.backend import Module, BackendConfig
from weboob.capabilities.captcha import CapCaptchaSolver, ImageCaptchaJob, RecaptchaJob, NocaptchaJob, FuncaptchaJob
from weboob.capabilities.captcha import (
CapCaptchaSolver, ImageCaptchaJob, RecaptchaJob, RecaptchaV3Job, NocaptchaJob, FuncaptchaJob
)
from weboob.tools.value import ValueBackendPassword
from .browser import AnticaptchaBrowser
......@@ -53,6 +55,8 @@ class AnticaptchaModule(Module, CapCaptchaSolver):
job.id = self.browser.post_image(job.image)
elif isinstance(job, RecaptchaJob):
job.id = self.browser.post_recaptcha(job.site_url, job.site_key)
elif isinstance(job, RecaptchaV3Job):
job.id = self.browser.post_gcaptchav3(job.site_url, job.site_key, job.action)
elif isinstance(job, NocaptchaJob):
job.id = self.browser.post_nocaptcha(job.site_url, job.site_key)
elif isinstance(job, FuncaptchaJob):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment