numberofaccounts = int(input("How many accounts to create?: ")) counter = 0 while True:…
- User
numberofaccounts = int(input("How many accounts to create?: ")) counter = 0
while True: while counter < numberofaccounts: while True: try: print("Waiting for captcha..") result = solver.recaptcha( sitekey='xxx-xxx', url='https://xxx.com/xxx', invisible=1)
except Exception as e: print("Captcha failed, retrying..") time.sleep(1) continue else: captchasolved = result["code"] print("Captcha solved creating account now. \n") break random_email = generate_random_email() random_username = generate_random_username() random_password = generate_random_password() payload = {"email": random_email, "password": random_password, "recaptcha": captchasolved, "username": random_username} headers = {"Content-Type":"application/json"} signupresponse = requests.post(signup, data=json.dumps(payload), headers=headers) if signupresponse.status_code == 200: counter += 1 accountscreated += 1 tokengenerated = signupresponse.cookies.get("connect.sid") print(f"\nAccount generated:\n{tokengenerated}\n------------------------------------------------------") with open("generatedAccounts.txt", "a") as file: file.write(f"'{tokengenerated}'\n") else: print(f"Error: {signupresponse.text}")print(f"{accountscreated} account(s) successfully created and saved.") input("Press any key to exit..")
When it generates the number of accounts I ask for, it seemslike the program gets stuck in an infinite loop, or crashes, why?
- Assistant
The issue is likely due to the fact that the outer
while Trueloop is causing the program to continue running indefinitely. Since there is no condition specified for breaking out of the outer loop, even after generating the desired number of accounts, the program will continue to execute indefinitely.