change api key
This commit is contained in:
@@ -3,11 +3,11 @@ import logging
|
|||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
CAPCHA_NOT_READY = "CAPCHA_NOT_READY"
|
CAPCHA_NOT_READY = "CAPCHA_NOT_READY"
|
||||||
REGEX_DATA_SITE_KEY = "data-sitekey=[\"a-z0-9A-Z]+"
|
REGEX_DATA_SITE_KEY = "data-sitekey=[\"a-z0-9A-Z]+"
|
||||||
|
API_KEY = "d66aaf490d8aa424a5175e1fbd1aadea"
|
||||||
|
|
||||||
|
|
||||||
class SolveCaptcha:
|
class SolveCaptcha:
|
||||||
@@ -28,23 +28,23 @@ class SolveCaptcha:
|
|||||||
if len(data_sitekey) == 1:
|
if len(data_sitekey) == 1:
|
||||||
key_with_comma = data_sitekey[0].split("=")[-1]
|
key_with_comma = data_sitekey[0].split("=")[-1]
|
||||||
key = key_with_comma.replace("\"", '')
|
key = key_with_comma.replace("\"", '')
|
||||||
print("key is : " + key)
|
self.logger.info("key is : " + key)
|
||||||
self.solve_captcha(key, handle_solution_received)
|
self.solve_captcha(key, handle_solution_received)
|
||||||
|
|
||||||
def solve_captcha(self, google_key: str, handle_solution_received):
|
def solve_captcha(self, google_key: str, handle_solution_received):
|
||||||
self.logger.info("solve_captcha()")
|
self.logger.info("solve_captcha()")
|
||||||
url_get = "http://2captcha.com/in.php?key=e7e3cd0977aba2dab49e0ea052ca58b1&method=userrecaptcha&googlekey={}&pageurl={}".format(
|
url_get = "http://2captcha.com/in.php?key={}&method=userrecaptcha&googlekey={}&pageurl={}".format(API_KEY,
|
||||||
google_key, self.page.url)
|
google_key,
|
||||||
|
self.page.url)
|
||||||
res = requests.get(url_get)
|
res = requests.get(url_get)
|
||||||
|
self.logger.info(res.text)
|
||||||
print(res.text)
|
|
||||||
results = res.text.split("|")
|
results = res.text.split("|")
|
||||||
self.captcha_id = results[-1]
|
self.captcha_id = results[-1]
|
||||||
# wait for 15 seconds
|
# wait for 15 seconds
|
||||||
time.sleep(15)
|
time.sleep(15)
|
||||||
# get result of the captcha
|
# 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)
|
self.captcha_id)
|
||||||
solution = CAPCHA_NOT_READY
|
solution = CAPCHA_NOT_READY
|
||||||
while solution == CAPCHA_NOT_READY:
|
while solution == CAPCHA_NOT_READY:
|
||||||
solution_res = requests.get(url_response)
|
solution_res = requests.get(url_response)
|
||||||
|
|||||||
Reference in New Issue
Block a user