welin 3 周之前
父节点
当前提交
c42dfb9649
共有 1 个文件被更改,包括 79 次插入25 次删除
  1. 79 25
      tls_registration_bot.py

+ 79 - 25
tls_registration_bot.py

@@ -19,6 +19,80 @@ from utils.mouse import HumanMouse
 from utils.keyboard import HumanKeyboard
 from utils.scroll import HumanScroll
 
+def generate_random_account_detail() -> Dict:
+    """基于 randomuser 生成随机账户信息,并保留指定固定字段。"""
+    default_payload = {
+        "email": f"user{random.randint(100000, 999999)}@gmail-app.com",
+        "pwd": "Visafly@111",
+        "location": "London",
+        "visa_type": "Short stay (<90 days) - Tourism",
+        "travel_purpose": "Tourism / Private visit",
+        "application_form_id": "FRA" + "".join(str(random.randint(0, 9)) for _ in range(14)),
+        "last_name": "Smith",
+        "first_name": "James",
+        "gender": "Male",
+        "birthday": "1998-11-20",
+        "nationality": "United Kingdom",
+        "province_residence": "London",
+        "passport_type": "Ordinary passport",
+        "passport_no": "".join(random.choices("ABCDEFGHIJKLMNOPQRSTUVWXYZ", k=2)) + "".join(random.choices("0123456789", k=7)),
+        "phone_country_code": "44",
+        "phone_number": "7400000000",
+        "departure_origin_date": "2026-05-26",
+        "arrival_schengen_area_date": "2026-05-26",
+        "departure_schengen_area_date": "2026-05-28",
+    }
+
+    try:
+        # 每次请求不传 seed,randomuser 会返回不同用户
+        resp = requests.get("https://randomuser.me/api/?nat=gb", timeout=15)
+        resp.raise_for_status()
+        raw = resp.json()
+        result = (raw.get("results") or [None])[0]
+        if not result:
+            return default_payload
+
+        first_name = result.get("name", {}).get("first") or default_payload["first_name"]
+        last_name = result.get("name", {}).get("last") or default_payload["last_name"]
+        gender_raw = (result.get("gender") or "").strip().lower()
+        gender = "Male" if gender_raw == "male" else "Female"
+        birthday_raw = result.get("dob", {}).get("date", "")
+        birthday = birthday_raw[:10] if birthday_raw else default_payload["birthday"]
+        city = result.get("location", {}).get("city") or default_payload["location"]
+        state = result.get("location", {}).get("state") or default_payload["province_residence"]
+        country = result.get("location", {}).get("country") or default_payload["nationality"]
+        phone_raw = result.get("cell") or result.get("phone") or default_payload["phone_number"]
+        phone_number = re.sub(r"\D", "", phone_raw) or default_payload["phone_number"]
+
+        email_prefix = re.sub(r"[^a-z0-9]", "", f"{first_name}{last_name}".lower())
+        if not email_prefix:
+            email_prefix = f"user{random.randint(100000, 999999)}"
+        email = f"{email_prefix}{random.randint(1000, 9999)}@gmail-app.com"
+
+        return {
+            "email": email,
+            "pwd": "Visafly@111",
+            "location": city,
+            "visa_type": "Short stay (<90 days) - Tourism",
+            "travel_purpose": "Tourism / Private visit",
+            "application_form_id": "FRA" + "".join(str(random.randint(0, 9)) for _ in range(14)),
+            "last_name": last_name,
+            "first_name": first_name,
+            "gender": gender,
+            "birthday": birthday,
+            "nationality": country,
+            "province_residence": state,
+            "passport_type": "Ordinary passport",
+            "passport_no": "".join(random.choices("ABCDEFGHIJKLMNOPQRSTUVWXYZ", k=2)) + "".join(random.choices("0123456789", k=7)),
+            "phone_country_code": "44",
+            "phone_number": phone_number,
+            "departure_origin_date": "2026-05-26",
+            "arrival_schengen_area_date": "2026-05-26",
+            "departure_schengen_area_date": "2026-05-28",
+        }
+    except Exception:
+        return default_payload
+
 class TlsRegistrator:
     def __init__(self, tls_url, proxy_config: Optional[Dict]=None, capsolver_key: Optional[str]=None, account_detail: Optional[Dict]=None):
         self.proxy_config = proxy_config
@@ -465,35 +539,15 @@ if __name__ == "__main__":
     
     CAPSOLVER_KEY = "CAP-5441DD341DD3CC2FAEF0BE6FE493EE9A"
     TLS_URL =  "https://visas-fr.tlscontact.com/en-us/country/cn/vac/cnCNG2fr"
-    ACCOUNT_DETAIL = {
-        "email": "lisi110@gmail-app.com",
-        "pwd": "Visafly@111",
-        "location": "Chengdu",
-        "visa_type": "Short stay (<90 days) - Tourism",
-        "travel_purpose": "Tourism / Private visit",
-        "application_form_id": "FRA1CA20260419573",
-        "last_name": "Song",
-        "first_name": "Xiaoyan",
-        "gender": "Male",
-        "birthday": "1998-12-20",
-        "nationality": "China",
-        "province_residence": "Sichuan",
-        "passport_type": "Ordinary passport",
-        "passport_no": "EJ8623112",
-        "phone_country_code": "86",
-        "phone_number": "18386037738",
-        "departure_origin_date": "2026-05-26",
-        "arrival_schengen_area_date": "2026-05-26",
-        "departure_schengen_area_date": "2026-05-28"
-    }
+    ACCOUNT_DETAIL = generate_random_account_detail()
     # ============================================
     try:
         bot = TlsRegistrator(TLS_URL, proxy_config=PROXY_CONFIG, capsolver_key=CAPSOLVER_KEY, account_detail=ACCOUNT_DETAIL)
         bot.init_browser()
-        # now_utc = datetime.utcnow()
-        # sent_at = now_utc.strftime("%Y-%m-%d %H:%M:%S")
-        # bot.register() 
-        # bot.activate(sent_at=sent_at)
+        now_utc = datetime.utcnow()
+        sent_at = now_utc.strftime("%Y-%m-%d %H:%M:%S")
+        bot.register() 
+        bot.activate(sent_at=sent_at)
         bot.make_account_useful()
     except Exception as e:
         print(f'Exception Info={e}')