From ca5539ef3411e16914e60ee0a845b335ea2344d6 Mon Sep 17 00:00:00 2001 From: Florian Duguet Date: Wed, 26 Jun 2019 17:50:08 +0200 Subject: [PATCH] [anticaptcha] manage Recaptcha v3 --- modules/anticaptcha/browser.py | 18 ++++++++++++++++-- modules/anticaptcha/module.py | 6 +++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/anticaptcha/browser.py b/modules/anticaptcha/browser.py index ce8c8a238b..14a462d98e 100644 --- a/modules/anticaptcha/browser.py +++ b/modules/anticaptcha/browser.py @@ -24,7 +24,7 @@ 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 @@ def post_gcaptcha(self, url, key, prefix): 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 @@ def poll(self, job): 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'] diff --git a/modules/anticaptcha/module.py b/modules/anticaptcha/module.py index c072fc65bf..6d1674ca94 100644 --- a/modules/anticaptcha/module.py +++ b/modules/anticaptcha/module.py @@ -21,7 +21,9 @@ 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 @@ def create_job(self, job): 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): -- GitLab