diff --git a/fir_ser/common/libs/geetest/geetest_lib.py b/fir_ser/common/libs/geetest/geetest_lib.py index 8878e76..12c604e 100644 --- a/fir_ser/common/libs/geetest/geetest_lib.py +++ b/fir_ser/common/libs/geetest/geetest_lib.py @@ -1,17 +1,21 @@ import hashlib import hmac import json +import logging import random import requests -from .geetest_lib_result import GeetestLibResult +from common.libs.geetest.geetest_lib_result import GeetestLibResult +from xsign.utils.iproxy import get_proxy_ip_from_cache + +logger = logging.getLogger(__name__) # sdk lib包,核心逻辑。 class GeetestLib: IS_DEBUG = False # 调试开关,是否输出调试日志 - API_URL = "http://api.geetest.com" + API_URL = "https://api.geetest.com" REGISTER_URL = "/register.php" VALIDATE_URL = "/validate.php" JSON_FORMAT = "1" @@ -28,8 +32,7 @@ class GeetestLib: self.libResult = GeetestLibResult() def gtlog(self, message): - if self.IS_DEBUG: - print("gtlog: " + message) + logger.debug(f"gtlog: {message}") # 验证初始化 def register(self, digestmod, param_dict): @@ -44,7 +47,8 @@ class GeetestLib: register_url = self.API_URL + self.REGISTER_URL self.gtlog("requestRegister(): 验证初始化, 向极验发送请求, url={0}, params={1}.".format(register_url, param_dict)) try: - res = requests.get(register_url, params=param_dict, timeout=self.HTTP_TIMEOUT_DEFAULT) + res = requests.get(register_url, params=param_dict, timeout=self.HTTP_TIMEOUT_DEFAULT, + proxies=get_proxy_ip_from_cache('geetes')) res_body = res.text if res.status_code == requests.codes.ok else "" self.gtlog("requestRegister(): 验证初始化, 与极验网络交互正常, 返回码={0}, 返回body={1}.".format(res.status_code, res_body)) res_dict = json.loads(res_body) @@ -122,7 +126,8 @@ class GeetestLib: validate_url = self.API_URL + self.VALIDATE_URL self.gtlog("requestValidate(): 二次验证 正常模式, 向极验发送请求, url={0}, params={1}.".format(validate_url, param_dict)) try: - res = requests.post(validate_url, data=param_dict, timeout=self.HTTP_TIMEOUT_DEFAULT) + res = requests.post(validate_url, data=param_dict, timeout=self.HTTP_TIMEOUT_DEFAULT, + proxies=get_proxy_ip_from_cache('geetes')) res_body = res.text if res.status_code == requests.codes.ok else "" self.gtlog( "requestValidate(): 二次验证 正常模式, 与极验网络交互正常, 返回码={0}, 返回body={1}.".format(res.status_code, res_body)) diff --git a/fir_ser/config.py b/fir_ser/config.py index 0e0edab..df58643 100644 --- a/fir_ser/config.py +++ b/fir_ser/config.py @@ -269,7 +269,6 @@ class IPACONF(object): {'proxy': '121.89.194.26:17897', 'active': True}, {'proxy': '39.103.139.122:17897', 'active': True}, {'proxy': '8.142.99.245:17897', 'active': True}, - {'proxy': '8.142.180.88:17897', 'active': True}, {'proxy': '8.142.174.13:17897', 'active': True}, {'proxy': '39.99.238.93:17897', 'active': True}, {'proxy': '8.142.173.96:17897', 'active': True},