0.1.2
This commit is contained in:
@@ -22,7 +22,8 @@ class Auto:
|
|||||||
tab = self.browser.latest_tab
|
tab = self.browser.latest_tab
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
tab.wait(1)
|
tab.wait(1)
|
||||||
res = tab.ele('t:h1@text()=Sorry, you have been blocked',timeout=1)
|
res = tab.ele(
|
||||||
|
't:h1@text()=Sorry, you have been blocked', timeout=1)
|
||||||
if res:
|
if res:
|
||||||
logger.error("Cloudflare验证失败")
|
logger.error("Cloudflare验证失败")
|
||||||
return False
|
return False
|
||||||
@@ -88,7 +89,7 @@ class Auto:
|
|||||||
logger.debug("Cloudflare验证成功.")
|
logger.debug("Cloudflare验证成功.")
|
||||||
self.tab.wait(1.5)
|
self.tab.wait(1.5)
|
||||||
bol = self.tab.ele(
|
bol = self.tab.ele(
|
||||||
't:h1@text():Sorry, you have been blocked', timeout=1)
|
't:h1@text()=Sorry, you have been blocked', timeout=1)
|
||||||
if bol:
|
if bol:
|
||||||
logger.debug("ip被ban秒")
|
logger.debug("ip被ban秒")
|
||||||
return False
|
return False
|
||||||
@@ -143,6 +144,15 @@ class Auto:
|
|||||||
# logger.debug("异常界面")
|
# logger.debug("异常界面")
|
||||||
# self.tab.wait(1)
|
# self.tab.wait(1)
|
||||||
# return self.click_continue(bl=True)
|
# return self.click_continue(bl=True)
|
||||||
|
|
||||||
|
bol = self.tab.ele(
|
||||||
|
't:h1@text()=Sorry, you have been blocked', timeout=1)
|
||||||
|
if bol:
|
||||||
|
logger.debug("ip被ban秒")
|
||||||
|
# 刷新网页
|
||||||
|
self.tab.refresh()
|
||||||
|
self.tab.wait(1.5)
|
||||||
|
|
||||||
bol = self.tab.ele(
|
bol = self.tab.ele(
|
||||||
't:h2@text()=You are being rate limited', timeout=1)
|
't:h2@text()=You are being rate limited', timeout=1)
|
||||||
if bol:
|
if bol:
|
||||||
@@ -244,8 +254,8 @@ class Auto:
|
|||||||
# 随机返回一条 key 和 value
|
# 随机返回一条 key 和 value
|
||||||
return random.choice(list(mapping.items()))
|
return random.choice(list(mapping.items()))
|
||||||
|
|
||||||
|
|
||||||
# 随机实物
|
# 随机实物
|
||||||
|
|
||||||
def get_random_food(self, city: str, shop: str) -> list[str]:
|
def get_random_food(self, city: str, shop: str) -> list[str]:
|
||||||
"""
|
"""
|
||||||
随机选择 1~2 种食物类别,并为每个类别至少选择 1 个具体产品
|
随机选择 1~2 种食物类别,并为每个类别至少选择 1 个具体产品
|
||||||
@@ -408,33 +418,47 @@ class Auto:
|
|||||||
self.tab.ele(
|
self.tab.ele(
|
||||||
't:input@id=PrintName').set.value(last_name+' '+first_name)
|
't:input@id=PrintName').set.value(last_name+' '+first_name)
|
||||||
self.tab.wait(0.1)
|
self.tab.wait(0.1)
|
||||||
for i in range(3):
|
return self.submit_file(first_name, last_name, birthday, current_address, city, phone, postal_code, province, email, text)
|
||||||
bol = self.solve_cloudflare()
|
|
||||||
if not bol:
|
|
||||||
logger.debug("Cloudflare验证失败.")
|
|
||||||
self.tab.wait(0.1)
|
|
||||||
else:
|
|
||||||
logger.debug("Cloudflare验证成功.")
|
|
||||||
self.tab.wait(3)
|
|
||||||
logger.debug(f"点击Submit按钮")
|
|
||||||
self.tab.ele('t:button@text():Submit').click()
|
|
||||||
break
|
|
||||||
api.create_info(
|
|
||||||
first_name=first_name,
|
|
||||||
last_name=last_name,
|
|
||||||
birthday=birthday,
|
|
||||||
current_address=current_address,
|
|
||||||
city=city,
|
|
||||||
phone=phone,
|
|
||||||
postal_code=postal_code,
|
|
||||||
province=province,
|
|
||||||
email=email,
|
|
||||||
text=text
|
|
||||||
)
|
|
||||||
self.tab.wait(3)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"填写问卷失败: {e}")
|
logger.error(f"填写问卷失败: {e}")
|
||||||
|
|
||||||
|
# 提交问卷
|
||||||
|
def submit_file(self, first_name: str, last_name: str, birthday: str, current_address: str, city: str, phone: str, postal_code: str, province: str, email: str, text: str):
|
||||||
|
jc = 0
|
||||||
|
while True:
|
||||||
|
if jc >= 3:
|
||||||
|
logger.error("提交问卷失败")
|
||||||
|
return False
|
||||||
|
res = self.tab.ele(
|
||||||
|
't:h2@text()=CLAIM SUBMISSION CONFIRMATION', timeout=3)
|
||||||
|
if res:
|
||||||
|
logger.info("提交问卷成功")
|
||||||
|
api.create_info(
|
||||||
|
first_name=first_name,
|
||||||
|
last_name=last_name,
|
||||||
|
birthday=birthday,
|
||||||
|
current_address=current_address,
|
||||||
|
city=city,
|
||||||
|
phone=phone,
|
||||||
|
postal_code=postal_code,
|
||||||
|
province=province,
|
||||||
|
email=email,
|
||||||
|
text=text
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
|
||||||
|
bol = self.solve_cloudflare()
|
||||||
|
if not bol:
|
||||||
|
logger.debug("Cloudflare验证失败.")
|
||||||
|
self.tab.wait(1)
|
||||||
|
else:
|
||||||
|
logger.debug("Cloudflare验证成功.")
|
||||||
|
logger.debug(f"点击Submit按钮")
|
||||||
|
self.tab.ele('t:button@text():Submit').click()
|
||||||
|
self.tab.wait(3)
|
||||||
|
jc += 1
|
||||||
|
|
||||||
|
|
||||||
# 取对应城市的代理
|
# 取对应城市的代理
|
||||||
def get_proxy(city: str):
|
def get_proxy(city: str):
|
||||||
@@ -451,6 +475,7 @@ def get_proxy(city: str):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_random_proxy() -> list[str] | None:
|
def get_random_proxy() -> list[str] | None:
|
||||||
"""
|
"""
|
||||||
随机选择一个代理配置(按指纹浏览器数量随机取 IP)
|
随机选择一个代理配置(按指纹浏览器数量随机取 IP)
|
||||||
@@ -467,6 +492,7 @@ def get_random_proxy() -> list[str] | None:
|
|||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
"""指纹浏览器操作"""
|
"""指纹浏览器操作"""
|
||||||
# 创建指纹浏览器
|
# 创建指纹浏览器
|
||||||
|
|
||||||
@@ -560,7 +586,8 @@ def run_all_cities_concurrently(num: int):
|
|||||||
import threading
|
import threading
|
||||||
threads = []
|
threads = []
|
||||||
for i in range(num):
|
for i in range(num):
|
||||||
t = threading.Thread(target=run_random_ips_forever, name=f"random-ip-thread-{i}")
|
t = threading.Thread(target=run_random_ips_forever,
|
||||||
|
name=f"random-ip-thread-{i}")
|
||||||
t.start()
|
t.start()
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
logger.info(f"随机 IP 线程 {i} 已启动")
|
logger.info(f"随机 IP 线程 {i} 已启动")
|
||||||
@@ -594,7 +621,8 @@ def run_random_ips_concurrently(num: int):
|
|||||||
return
|
return
|
||||||
threads = []
|
threads = []
|
||||||
for i in range(num):
|
for i in range(num):
|
||||||
t = threading.Thread(target=run_random_ips_forever, name=f"random-ip-thread-{i}")
|
t = threading.Thread(target=run_random_ips_forever,
|
||||||
|
name=f"random-ip-thread-{i}")
|
||||||
t.start()
|
t.start()
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
logger.info(f"随机 IP 线程 {i} 已启动")
|
logger.info(f"随机 IP 线程 {i} 已启动")
|
||||||
|
|||||||
Reference in New Issue
Block a user