Cách Bypass CAPTCHA Khi Web Scraping (2026)
CAPTCHA là rào cản lớn nhất khi scraping. Bài viết hướng dẫn các phương pháp bypass CAPTCHA hiệu quả.
Các Loại CAPTCHA Phổ Biến
- reCAPTCHA v2: “I’m not a robot” checkbox
- reCAPTCHA v3: Invisible, score-based
- hCaptcha: Chọn hình ảnh
- Cloudflare Turnstile: Challenge mới
- Text CAPTCHA: Nhập chữ/số
Tại Sao Gặp CAPTCHA?
- Quá nhiều requests từ 1 IP
- Behavior không giống người
- Headless browser bị detect
- User-Agent bất thường
Phương Pháp Bypass
1. Tránh Trigger CAPTCHA
Phòng bệnh hơn chữa bệnh:
- Dùng residential proxy
- Random delays (2-5s)
- Rotate User-Agent
- Giả lập mouse movements
2. CAPTCHA Solving Services
# Ví dụ với 2Captcha
import requests
# Gửi CAPTCHA
response = requests.post("http://2captcha.com/in.php", data={
"key": "YOUR_API_KEY",
"method": "userrecaptcha",
"googlekey": "SITE_KEY",
"pageurl": "https://target.com"
})
# Nhận kết quả
captcha_id = response.text.split("|")[1]
result = requests.get(f"http://2captcha.com/res.php?key=API_KEY&action=get&id={captcha_id}")
token = result.text.split("|")[1]
3. Undetected ChromeDriver
import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get("https://protected-site.com")
# Tự động bypass nhiều protection
4. Puppeteer Stealth
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://protected-site.com');
CAPTCHA Solving Services
| Service | Giá | Speed |
|---|---|---|
| 2Captcha | $2.99/1000 | ~20s |
| Anti-Captcha | $2/1000 | ~15s |
| CapMonster | $1.5/1000 | ~10s |
Best Practices
- Ưu tiên tránh trigger trước
- Dùng residential proxy
- Giới hạn request rate
- Rotate sessions thường xuyên
VinaProxy – Giảm Thiểu CAPTCHA
- Residential IP ít bị challenge
- Auto-rotation tránh detection
- Giá chỉ $0.5/GB
