What i'm trying to do is run a piece of code that did work at one time, but when i loaded up the project the captcha solving function is saying i'm missing an argument in a function but i don't see where.
Code:
This piece of code:
elif action_to_take == "RECAPTCHA_V2":
selenium_field = self.execute_recaptcha_v2_solver(captcha_key, url_or_field_identifier)
self.write_to_debug_file("--> SOLVING RECAPTCHA V2 ...", _filename)
Then executes:
# this function executes the ReCaptcha solver ...
def execute_recaptcha_v2_solver(self, api_key, url_or_field_identifier):
solve_recaptcha_v2 = CaptchaReCaptchaSolver.solve_recaptcha(api_key,
self.extract_data_site_key(self.driver.page_source),
url_or_field_identifier)
javascript_code = 'document.getElementById("g-recaptcha-response").innerHTML = "{}"'.format(solve_recaptcha_v2)
return self.driver.execute_script(javascript_code)
Which runs the Class:
class CaptchaReCaptchaSolver(object):
# noinspection PyMethodMayBeStatic
def solve_recaptcha(self, _captcha_api_key, _site_key, _url):
print(_captcha_api_key, _site_key, _url)
""" this function solves recaptcha using 2captcha.com """
try:
# p = '127.0.0.1:6969'
# p = {'http': 'http://' + p, 'https': 'https://' + p}
# send off requests ...
s = requests.Session()
cap_id = s.post('http://2captcha.com/in.php?key={}&method=userrecaptcha&googlekey={}&pageurl={}'.format(
_captcha_api_key, _site_key, _url)).text.split('|')[1]
rec_an = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(_captcha_api_key, cap_id)).text
# tell us what is going on ...
print("--> ReCAPTCHA V2 SOLVING")
print("--> SOLVING ...")
while "CAPTCHA_NOT_READY" in rec_an:
sleep(5)
rec_an = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(_captcha_api_key, cap_id)).text
rec_an = rec_an.split('|')[1]
# solved ...
print("--> " + rec_an)
print("--> SOLVED ...")
print("--> ReCAPTCHA V2 RESPONSE")
# payload ...
payload = {'key': 'value', 'gresponse': rec_an}
s.post(_url, payload)
# return ReCaptcha answer ...
return rec_an
except Exception as e:
print("2CAPTCHA.COM [ReCAPTCHA] ERROR: ", e)
The error is:
LINE 222 "selenium_field = self.execute_recaptcha_v2_solver(captcha_key, url_or_field_identifier)"): solve_recaptcha() missing 1 required positional argument: '_url'
The class method solve_recaptcha()
is missing an argument it is saying, but i have printed them out and they are all there, am i missing something obvious? i cannot see what the issue could be, any help would be appreciated.