while True: while True: try: print("Waiting for captcha..") result = solver.recaptcha(…
- User
while True: while True: try: print("Waiting for captcha..") result = solver.recaptcha( sitekey='xxx', url='https://xxx.com/_api/auth/login', invisible=1)
except Exception as e: print("Captcha failed, retrying..") continue else: captchasolved = result["code"] print(f"Captcha solved, logging into {email} now. \n") breakCreate a dictionary with the email and password
data = {"email": email, "password": password, "recaptcha": captchasolved}Login with username, password, and recaptcha
while True: response = requests.post(url, json=data) #Check if successful login if response.status_code != 200: token = response.cookies.get("connect.sid") print(response.status_code) print(response.text) print(f"Valid credentials, attempting to create valid session for {email}") # Enter the same 2FA code a few times validate_response = requests.get(validate_url + code, cookies={"connect.sid":token}) if validate_response.status_code == 200: accountstats = requests.get(ACCOUNTGRABURL, cookies={"connect.sid":token}) if accountstats.status_code == 200: print(accountstats.text) print(accountstats.cookies.get("connect.sid")) input("Press enter to exit") sys.exit() else: print(accountstats.status_code) print(accountstats.text) input("Press enter to exit..") sys.exit() else: print(f"Error when signing in to {email}: {response.text}. Trying again...\n-------------------------") time.sleep(5) breakIt keeps looping print(accountstats.status_code) print(accountstats.text)
What did i do wrong?
- Assistant
It appears that you may have an issue with the loop structure in your code. Specifically, the nested
while Trueloops may be causing the program to get stuck in an infinite loop.To address this issue, you may want to consider adding a condition to break out of the inner loop once a successful login has been achieved. This could be done by setting a flag or condition that checks if the login was successful, and then breaking out of the loop accordingly.
Additionally, you may want to add error handling to gracefully handle any exceptions or errors that may occur during the login process, to avoid getting stuck in an infinite loop when errors occur.
By restructuring your code and adding appropriate error handling and conditions to break out of the loops when necessary, you should be able to resolve the issue of the code getting stuck in a loop.
- User
Help me
- Assistant