|
|
@@ -100,6 +100,42 @@ def generate_random_account_detail() -> Dict:
|
|
|
}
|
|
|
except Exception:
|
|
|
return default_payload
|
|
|
+
|
|
|
+def upload_account_to_server(account):
|
|
|
+ """
|
|
|
+ 将注册成功的账号上报到中心服务器
|
|
|
+ """
|
|
|
+ api_url = 'https://visafly.top/api/account/add'
|
|
|
+ api_token = 'tok_e946329a60ff45ba807f3f41b0e8b7fc' # 你的 Bearer Token
|
|
|
+
|
|
|
+ # 构造请求头
|
|
|
+ headers = {
|
|
|
+ 'accept': 'application/json',
|
|
|
+ 'Authorization': f'Bearer {api_token}',
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ }
|
|
|
+
|
|
|
+ # 构造主 Payload
|
|
|
+ payload = {
|
|
|
+ "pool_name": account.get("pool_name", "default_pool"),
|
|
|
+ "username": account.get("email"),
|
|
|
+ "password": account.get("password"),
|
|
|
+ "extra_data": account
|
|
|
+ }
|
|
|
+
|
|
|
+ try:
|
|
|
+ logger.info(f"Uploading account {account['email']} to server...")
|
|
|
+ resp = requests.post(api_url, json=payload, headers=headers, timeout=10)
|
|
|
+
|
|
|
+ if resp.status_code == 200:
|
|
|
+ logger.info(f"✅ [API Upload Success] Server responded: {resp.text}")
|
|
|
+ return True
|
|
|
+ else:
|
|
|
+ logger.error(f"❌ [API Upload Failed] Status: {resp.status_code}, Body: {resp.text}")
|
|
|
+ return False
|
|
|
+ except Exception as e:
|
|
|
+ logger.error(f"❌ [API Upload Error]: {e}")
|
|
|
+ return False
|
|
|
|
|
|
class TlsRegistrator:
|
|
|
def __init__(self, tls_url, proxy_config: Optional[Dict]=None, capsolver_key: Optional[str]=None, account_detail: Optional[Dict]=None):
|
|
|
@@ -167,43 +203,7 @@ class TlsRegistrator:
|
|
|
viewport_height = self.page.rect.viewport_size[1]
|
|
|
init_x = random.randint(10, viewport_width - 10)
|
|
|
init_y = random.randint(10, viewport_height - 10)
|
|
|
- self.mouse.move(init_x, init_y)
|
|
|
-
|
|
|
- def upload_account_to_server(self):
|
|
|
- """
|
|
|
- 将注册成功的账号上报到中心服务器
|
|
|
- """
|
|
|
- api_url = 'https://visafly.top/api/account/add'
|
|
|
- api_token = 'tok_e946329a60ff45ba807f3f41b0e8b7fc' # 你的 Bearer Token
|
|
|
-
|
|
|
- # 构造请求头
|
|
|
- headers = {
|
|
|
- 'accept': 'application/json',
|
|
|
- 'Authorization': f'Bearer {api_token}',
|
|
|
- 'Content-Type': 'application/json'
|
|
|
- }
|
|
|
-
|
|
|
- # 构造主 Payload
|
|
|
- payload = {
|
|
|
- "pool_name": self.account_detail.get("pool_name", "default_pool"),
|
|
|
- "username": self.account_detail.get("email"),
|
|
|
- "password": self.account_detail.get("password"),
|
|
|
- "extra_data": self.account_detail
|
|
|
- }
|
|
|
-
|
|
|
- try:
|
|
|
- self._log(f"Uploading account {self.account_detail['email']} to server...")
|
|
|
- resp = requests.post(api_url, json=payload, headers=headers, timeout=10)
|
|
|
-
|
|
|
- if resp.status_code == 200:
|
|
|
- self._log(f"✅ [API Upload Success] Server responded: {resp.text}")
|
|
|
- return True
|
|
|
- else:
|
|
|
- self._log(f"❌ [API Upload Failed] Status: {resp.status_code}, Body: {resp.text}")
|
|
|
- return False
|
|
|
- except Exception as e:
|
|
|
- self._log(f"❌ [API Upload Error]: {e}")
|
|
|
- return False
|
|
|
+ self.mouse.move(init_x, init_y)
|
|
|
|
|
|
def solve_captcha(self, page_url: str, task_type: str, site_key: str, use_proxy = False, action: str = None, api_domain: str = None) -> str:
|
|
|
"""通用解决验证码 (同步 User-Agent 防止被盾识别为高风险)"""
|
|
|
@@ -336,7 +336,6 @@ class TlsRegistrator:
|
|
|
raise BizLogicError(message=f"Wait ele={btn_selector} timeout")
|
|
|
self.page.ele(btn_selector).click()
|
|
|
time.sleep(3)
|
|
|
- return True
|
|
|
|
|
|
def make_account_useful(self):
|
|
|
|
|
|
@@ -559,7 +558,6 @@ class TlsRegistrator:
|
|
|
submit_btn = self.page.ele('tag:button@@text():Confirm')
|
|
|
submit_btn.scroll.to_see(center=True)
|
|
|
submit_btn.click()
|
|
|
- return True
|
|
|
|
|
|
def cleanup(self):
|
|
|
"""清理浏览器进程和缓存文件夹"""
|
|
|
@@ -592,10 +590,10 @@ if __name__ == "__main__":
|
|
|
bot.init_browser()
|
|
|
now_utc = datetime.utcnow()
|
|
|
sent_at = now_utc.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
- bot.register()
|
|
|
+ bot.register()
|
|
|
bot.activate(sent_at=sent_at)
|
|
|
bot.make_account_useful()
|
|
|
- bot.upload_account_to_server()
|
|
|
+ upload_account_to_server(ACCOUNT_DETAIL)
|
|
|
except Exception as e:
|
|
|
print(f'Exception Info={e}')
|
|
|
time.sleep(3600)
|