change api key

This commit is contained in:
PAN Lei
2022-05-27 13:18:07 +02:00
parent 1b446965aa
commit 9ce2ba343c
+7 -7
View File
@@ -3,11 +3,11 @@ import logging
import random
import re
import time
import requests
CAPCHA_NOT_READY = "CAPCHA_NOT_READY"
REGEX_DATA_SITE_KEY = "data-sitekey=[\"a-z0-9A-Z]+"
API_KEY = "d66aaf490d8aa424a5175e1fbd1aadea"
class SolveCaptcha:
@@ -28,22 +28,22 @@ class SolveCaptcha:
if len(data_sitekey) == 1:
key_with_comma = data_sitekey[0].split("=")[-1]
key = key_with_comma.replace("\"", '')
print("key is : " + key)
self.logger.info("key is : " + key)
self.solve_captcha(key, handle_solution_received)
def solve_captcha(self, google_key: str, handle_solution_received):
self.logger.info("solve_captcha()")
url_get = "http://2captcha.com/in.php?key=e7e3cd0977aba2dab49e0ea052ca58b1&method=userrecaptcha&googlekey={}&pageurl={}".format(
google_key, self.page.url)
url_get = "http://2captcha.com/in.php?key={}&method=userrecaptcha&googlekey={}&pageurl={}".format(API_KEY,
google_key,
self.page.url)
res = requests.get(url_get)
print(res.text)
self.logger.info(res.text)
results = res.text.split("|")
self.captcha_id = results[-1]
# wait for 15 seconds
time.sleep(15)
# get result of the captcha
url_response = "http://2captcha.com/res.php?key=e7e3cd0977aba2dab49e0ea052ca58b1&action=get&id={}".format(
url_response = "http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY,
self.captcha_id)
solution = CAPCHA_NOT_READY
while solution == CAPCHA_NOT_READY: