There was a similar question on stack overflow in the 21st year Submitting hcaptcha captcha token to Discord to create an account using selenium but, firstly, they did not give a clear answer, and secondly, everything has changed in 4 years, and the scripts that were offered there no longer work. What's the point. I'm trying to create a bot in discord automatically using python and the selenium library, but to do this, after entering the name of the bot, you need to go through a captcha. To bypass this, I use the 2captcha service, which works according to the principle: I send a sitekey to discord, he sends me a solution in the form of a string that needs to be inserted into the response field (h-captcha-response). The problem is that, unlike other sites, discord checks the correctness of the completed captcha itself, without the "Send", "Verify", etc. buttons. I've been puzzling over how to get around this for a very long time. The neural networks replied that there was a hidden script in the discord to check the captcha, and you need to activate the trigger to make it count. They did not find the trigger itself, even after completely removing the HTML code of the site. I also tried to find it myself, but I couldn't. Please help, it was because of this problem that I abandoned my project the previous year, decided to return now with renewed vigor, and still could not figure it out. I will attach the code that already exists below. Just after the comment # Inserting into the code and activating the captcha check there must be a code that I couldn't write async def _process_log_entry(entry: dict): message = entry.get("message", "") if 'captcha' not in message or 'sitekey' not in message: return None try: data = json.loads(message) post_data = (data.get("message", {}) .get("params", {}) .get("request", {}) .get("postData")) if not post_data: return None events = json.loads(post_data).get("events", []) if events: return events[0].get("properties", {}).get("sitekey") except (json.JSONDecodeError, AttributeError, TypeError, KeyError) as e: return None return None async def get_sitekey(driver: webdriver.Chrome, timeout=5): for attempt in range(timeout): try: log_entries = driver.get_log("performance") for entry in log_entries: if sitekey := await _process_log_entry(entry): return sitekey await asyncio.sleep(1) return None except selenium.common.exceptions.InvalidArgumentException as e: await asyncio.sleep(1) return None return None # FIXME async def bypass_captcha(driver, sitekey): loop = asyncio.get_running_loop() solve = TwoCaptcha(tk.captcha_api_key) with concurrent.futures.ThreadPoolExecutor() as pool: for _ in range(3): try: result = await loop.run_in_executor(pool, lambda: solve.hcaptcha(sitekey=sitekey, url=driver.current_url)) except (ApiException, twocaptcha.api.ApiException, twocaptcha.solver.ApiException, twocaptcha.solver.TimeoutException) as e: print(e) continue break else: raise ApiException("All attempts to solve the captcha were unsuccessful") hcaptcha_solution = result['code'] # Inserting into the code and activating the captcha check return solve Plus this piece of code (if needed): chrome_options = webdriver.ChromeOptions() chrome_options.set_capability( "goog:loggingPrefs", {"performance": "ALL", "browser": "ALL"} ) driver = webdriver.Chrome(options=chrome_options) driver.get("https://discord.com/developers/applications") Thank you in advance for your help P.S. I assume that you may need JS for the solution, so I'll add it to the tags. Continue reading...