
CAPTCHAs stop over 90% of bots dead in their tracks. And for good reason — they're built to separate humans from machines. But what if your automation is legit? What if your Selenium scripts keep hitting this brick wall and get stuck? Frustrating, right?
You can bypass CAPTCHA automatically. Not by hacking it, but by integrating smart tools that handle the heavy lifting for you. This guide walks you through exactly how to do it. Step by step.
Don't start without these essentials:
Python & Selenium installed
Run this if you haven't yet:
pip install --upgrade selenium
A CAPTCHA-solving service
Services like 2Captcha or Anti-Captcha are your best friends here. Sign up, grab an API key, and get ready to automate CAPTCHA solving.
Proxies
Rotating proxies help avoid triggering CAPTCHAs frequently. Proxy Services offer some plans to get you started. Using proxies lowers costs by reducing CAPTCHA requests.
Supporting libraries
To connect with 2Captcha easily, install their Python client:
pip install 2captcha-python
Here's how to plug everything together and get your script flying over those CAPTCHAs.
Bring in Selenium, 2Captcha client, and time for pacing:
from selenium.webdriver.common.by import By  
from twocaptcha import TwoCaptcha  
from selenium import webdriver  
import time  
Make sure you have the correct WebDriver for your browser. Then:
driver = webdriver.Chrome()  # ChromeDriver must be installed and in PATH  
url = "https://2captcha.com/demo/normal"  # Testing page with CAPTCHA  
driver.get(url)  
Find the CAPTCHA image URL, send it to 2Captcha, and get the answer:
img = driver.find_element(By.XPATH, "//img[contains(@class,'_2hXzbgz7SSP0DXCyvKWcha')]")  
solver = TwoCaptcha('Your_2Captcha_API_key')  
result = solver.normal(img.get_attribute("src"))  
print("CAPTCHA solved:", result)  
Paste the solved code into the form and submit it:
captcha_input = driver.find_element(By.XPATH, "//input[contains(@class,'_26Pq0m_qFk19UXx1w0U5Kv')]")  
captcha_input.send_keys(result["code"])  
submit_btn = driver.find_element(By.XPATH, "//button[contains(@class, 'l2z7-tVRGe-3sq5kU4uu5')]")  
submit_btn.click()  
time.sleep(10)  # Wait for response  
Check the page for a success message:
message = driver.find_element(By.XPATH, "//p[contains(@class,'_2WOJoV7Dg493S8DW_GobSK')]")  
print("Result:", message.text)  # Should confirm success!  
Many sites detect headless browsers and block them — even with custom user-agents.
Fix: Use tools like undetected-chromedriver which hide Selenium's footprints better.
Here's a quick setup:
from undetected_chromedriver.v2 import Chrome, ChromeOptions  
options = ChromeOptions()  
options.add_argument('--headless')  
options.add_argument('user-agent=your_custom_user_agent')  
driver = Chrome(options=options)  
Sometimes the custom user-agent applies only once, causing detection later.
Fix: Set your user-agent consistently when initializing the driver:
options = webdriver.ChromeOptions()  
options.add_argument('user-agent=your_custom_user_agent')  
driver = webdriver.Chrome(options=options)  
Your browser crashes or fails silently with headless + user-agent options.
Fix: Explicitly set window size and GPU flags:
options = webdriver.ChromeOptions()  
options.add_argument('user-agent=your_custom_user_agent')  
options.add_argument('--headless')  
options.add_argument('--window-size=1920x1080')  
options.add_argument('--disable-gpu')  
driver = webdriver.Chrome(options=options)  
Automating CAPTCHA solving isn't magic — it's smart integration. Combine Selenium with reliable CAPTCHA-solving services, back it with proxy rotation, and stealthy browser settings, and you'll break through barriers that stop most bots cold.
 頂級住宅代理解決方案
頂級住宅代理解決方案 {{item.title}}
                                        {{item.title}}