|
|
@@ -100,42 +100,6 @@ 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):
|
|
|
@@ -558,6 +522,42 @@ class TlsRegistrator:
|
|
|
submit_btn = self.page.ele('tag:button@@text():Confirm')
|
|
|
submit_btn.scroll.to_see(center=True)
|
|
|
submit_btn.click()
|
|
|
+
|
|
|
+ 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:
|
|
|
+ (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
|
|
|
|
|
|
def cleanup(self):
|
|
|
"""清理浏览器进程和缓存文件夹"""
|