C¨¢ch t¨ªch h?p CapSolver v?i Selenium | H??ng d?n ho¨¤n ch?nh 2025

Anh Tuan
Data Science Expert
04-Sep-2025

Selenium l¨¤ g¨¬?
Selenium l¨¤ m?t c?ng c? ki?m th? t? ??ng m? ngu?n m?, ch? y?u ???c s? d?ng ?? t? ??ng h¨®a c¨¢c ?ng d?ng web. N¨® c?ng th??ng ???c s? d?ng ?? thu th?p d? li?u web v¨¤ t? ??ng h¨®a c¨¢c t??ng t¨¢c tr¨ºn trang web. Selenium c¨® th? m? ph?ng nhi?u h¨¤nh vi c?a ng??i d¨´ng trong tr¨¬nh duy?t, ch?ng h?n nh? nh?p chu?t, nh?p li?u, cu?n trang v¨¤ chuy?n trang. N¨® ???c ph¨¢t tri?n ban ??u b?i Jason Huggins v¨¤o n?m 2004 v¨¤ hi?n ?ang ???c duy tr¨¬ b?i nh¨®m d? ¨¢n Selenium. Selenium h? tr? nhi?u ng?n ng? l?p tr¨¬nh, bao g?m Python, Java, C#, Ruby v¨¤ JavaScript.
Selenium bao g?m c¨¢c th¨¤nh ph?n c?t l?i sau:
-
Selenium WebDriver (th??ng ???c s? d?ng nh?t)
- Cung c?p kh? n?ng ?i?u khi?n tr¨¬nh duy?t g?c, h? tr? c¨¢c tr¨¬nh duy?t ch¨ªnh nh? Chrome, Firefox, Edge v¨¤ Safari.
- C¨® th? m? ph?ng nhi?u h¨¤nh ??ng c?a tr¨¬nh duy?t nh? nh?p chu?t, nh?p li?u, cu?n trang v¨¤ chuy?n tab.
- M?i tr¨¬nh duy?t ??u c¨® tr¨¬nh ?i?u khi?n t??ng ?ng, ch?ng h?n nh?
chromedriver
ho?cgeckodriver
.
-
Selenium IDE
- M?t ti?n ¨ªch m? r?ng tr¨¬nh duy?t (cho Chrome/Firefox) cho ph¨¦p ghi l?i v¨¤ ph¨¢t l?i c¨¢c script ki?m th?. N¨® l? t??ng cho ng??i m?i b?t ??u ki?m th?.
-
Selenium Grid
- Cho ph¨¦p ki?m th? ph?n t¨¢n b?ng c¨¢ch t?o m?t l??i ki?m th? v?i nhi?u tr¨¬nh duy?t v¨¤ m¨¢y, cho ph¨¦p th?c hi?n song song c¨¢c script.
C¨¢c tr??ng h?p s? d?ng ph? bi?n
- Thu th?p d? li?u ??ng: Tr¨ªch xu?t d? li?u ???c t?o b?i vi?c hi?n th? JavaScript.
- X? l? c¨¢c t??ng t¨¢c ph?c t?p: Th¨ªch h?p ?? thu th?p d? li?u t? c¨¢c trang web y¨ºu c?u ??ng nh?p ho?c nhi?u b??c h¨¤nh ??ng ?? truy c?p d? li?u.
- Tr¨ªch xu?t d? li?u t? c¨¢c ?ng d?ng SPA: Thu th?p d? li?u t? c¨¢c trang ???c x?y d?ng b?ng c¨¢c framework nh? Vue ho?c React.
- Ki?m th? t? ??ng: X¨¢c th?c ch?c n?ng c?a trang trong khi ??ng th?i thu th?p d? li?u.
- L¨¤m vi?c v?i ch? ?? headless: Th?c hi?n t?t c? c¨¢c thao t¨¢c m¨¤ kh?ng c?n giao di?n ?? h?a, l? t??ng ?? ch?y tr¨ºn m¨¢y ch?.
C¨¢ch s? d?ng c? b?n c?a Selenium
?? s? d?ng Selenium trong Python:
bash
pip install selenium
?? s? d?ng Selenium v?i Chrome, h?y t?i xu?ng chromedriver
ph¨´ h?p v?i phi¨ºn b?n Chrome c?a b?n t? Github
V¨ª d?: S? d?ng Selenium ?? l?y t?t c? ti¨ºu ?? b¨¤i ??ng blog t? blog c?a CapSolver:
python
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
# Ch? ??nh ???ng d?n chromedriver (n?u ?? ???c th¨ºm v¨¤o PATH, c¨® th? b? qua)
service = Service(executable_path="chromedriver.exe")
driver = webdriver.Chrome(options=chrome_options, service=service)
try:
driver.get("/blog/All")
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, 'h5')))
h5_elements = driver.find_elements(By.TAG_NAME, "h5")
for el in h5_elements:
print(el.text.strip())
finally:
driver.quit()
C¨¢ch t¨ªch h?p ti?n ¨ªch m? r?ng CapSolver v?i Selenium
Selenium l¨¤ m?t c?ng c? m?nh m? h? tr? t?i c¨¢c ti?n ¨ªch m? r?ng tr¨¬nh duy?t gi?ng nh? m?t tr¨¬nh duy?t th?ng th??ng.
-
T?i xu?ng g¨®i
.zip
ti?n ¨ªch m? r?ng m?i nh?t t? GitHub ch¨ªnh th?c c?a CapSolver v¨¤ gi?i n¨¦n:
? https://github.com/capsolver/capsolver-browser-extension/releases -
Trong c¨¢c t¨´y ch?n kh?i ??ng c?a Selenium, s? d?ng ??i s?
load-extension
?? ch? ??nh ???ng d?n ti?n ¨ªch m? r?ng:
python
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("load-extension=/path/to/capSolver extension")
# Ch? ??nh ???ng d?n chromedriver (b? qua n?u ?? c¨® trong PATH)
service = Service(executable_path="chromedriver.exe")
driver = webdriver.Chrome(options=chrome_options, service=service)
try:
driver.get("/blog/All")
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, 'h5')))
h5_elements = driver.find_elements(By.TAG_NAME, "h5")
for el in h5_elements:
print(el.text.strip())
finally:
driver.quit()
?? L?u ?: N?u b?n ?ang s? d?ng Chrome v137, b?n c¨® th? c?n th¨ºm m?t ??i s? b? sung:
python
chrome_options.add_argument("--disable-features=DisableLoadExtensionCommandLineSwitch")
Chi ti?t h?n: SeleniumHQ. C¨¢c phi¨ºn b?n kh¨¢c nhau c¨® th? ho?t ??ng kh¨¢c nhau¡ªh?y ?i?u ch?nh theo m?i tr??ng c?a b?n.
S? d?ng ti?n ¨ªch m? r?ng CapSolver ?? gi?i quy?t reCAPTCHA v2
CAPTCHAs nh? reCAPTCHA, Cloudflare Turnstile, AWS WAF v¨¤ GeeTest ???c s? d?ng r?ng r?i tr¨ºn h¨¤ng ngh¨¬n trang web. Tuy nhi¨ºn, c?u tr¨²c DOM c?a ch¨²ng v?n ch? y?u nh?t qu¨¢n tr¨ºn c¨¢c trang web. Ti?n ¨ªch m? r?ng CapSolver c¨® th? t? ??ng ph¨¢t hi?n v¨¤ gi?i quy?t c¨¢c CAPTCHA n¨¤y d?a tr¨ºn c¨¢c ??c ?i?m ri¨ºng bi?t c?a ch¨²ng¡ªkh?ng c?n t??ng t¨¢c th? c?ng.
H?y l?y reCAPTCHA v2 l¨¤m v¨ª d? v¨¤ ch?ng minh c¨¢ch s? d?ng ti?n ¨ªch m? r?ng CapSolver trong Selenium ?? b? qua n¨®.
(L?u ?: tr? khi ???c ch? ??nh kh¨¢c, b?n demo sau ??y s? d?ng ch? ?? click
: ???c ??t trong /assets/config.js ¡ú reCaptchaMode: 'click'
)
?? ??ng qu¨ºn gi?i n¨¦n ti?n ¨ªch m? r?ng v¨¤ c?u h¨¬nh
apiKey
c?a b?n trong/assets/config.js
python
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
# B??c 1: L?y ti?n ¨ªch m? r?ng t? GitHub: https://github.com/capsolver/capsolver-browser-extension/releases
# B??c 2: Gi?i n¨¦n ti?n ¨ªch m? r?ng v¨¤ ??t apiKey c?a b?n trong /assets/config.js
chrome_options.add_argument("load-extension=/path/to/CapSolver Browser Extension-v1.16.0")
# Ch? ??nh ???ng d?n chromedriver (b? qua n?u ?? c¨® trong PATH)
service = Service(executable_path="chromedriver.exe")
driver = webdriver.Chrome(options=chrome_options, service=service)
try:
driver.get("https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php")
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'form[action="/recaptcha-v2-checkbox.php"]')))
# Ti?n ¨ªch m? r?ng s? t? ??ng ph¨¢t hi?n v¨¤ gi?i quy?t reCAPTCHA
time.sleep(15)
# Sau khi gi?i quy?t, nh?p v¨¤o n¨²t g?i
submit_button = driver.find_element(By.CSS_SELECTOR, 'button[type="submit"]')
submit_button.click()
time.sleep(3)
except Exception as error:
print(error)
finally:
driver.quit()
Ti?n ¨ªch m? r?ng CapSolver c?ng h? tr? nhi?u t¨´y ch?n c?u h¨¬nh h?u ¨ªch. T?t c? c¨¢c c¨¤i ??t c¨® th? ???c ?i?u ch?nh trong t?p
/assets/config.js
.
T¨´y ch?n c?u h¨¬nh solvedCallback
Trong v¨ª d? tr??c, ch¨²ng ta ?? ch? 15 gi?y sau khi t?i trang tr??c khi nh?p v¨¤o n¨²t g?i. Kho?ng th?i gian ch? n¨¤y nh?m m?c ?¨ªch cung c?p cho ti?n ¨ªch m? r?ng CapSolver ?? th?i gian ?? t? ??ng gi?i quy?t reCAPTCHA.
Tuy nhi¨ºn, c¨¢ch ti?p c?n n¨¤y kh?ng tinh t?. Trong th?c t?, vi?c gi?i quy?t CAPTCHA c¨® th? m?t ¨ªt h?n 15 gi?y, ho?c trong tr??ng h?p m?ng ch?m, h?n 15 gi?y.
?? gi?i quy?t v?n ?? n¨¤y, CapSolver cung c?p m?t t¨´y ch?n c?u h¨¬nh g?i l¨¤ solvedCallback
. ?i?u n¨¤y cho ph¨¦p b?n ??nh ngh?a m?t h¨¤m callback ???c k¨ªch ho?t sau khi CAPTCHA ???c gi?i quy?t th¨¤nh c?ng. B?n c¨® th? t¨¬m th?y t¨´y ch?n solvedCallback
trong /assets/config.js
, v¨¤ b?n c¨® th? t¨´y ch?nh t¨ºn h¨¤m¡ªtheo m?c ??nh, ?¨® l¨¤ captchaSolvedCallback
.
N?u b?n ?ang s? d?ng Puppeteer ho?c Playwright, b?n c¨® th? hi?n th? h¨¤m callback n¨¤y cho ng? c?nh tr¨¬nh duy?t b?ng ph??ng ph¨¢p page.exposeFunction
. Xem:
C¨°n Python + Selenium th¨¬ sao?
Th?t kh?ng may, Selenium c?a Python kh?ng cung c?p m?t ch?c n?ng t??ng ???ng t¨ªch h?p s?n v?i page.exposeFunction
, v¨¬ v?y t¨ªnh n?ng solvedCallback
kh?ng th? ???c s? d?ng ??y ?? trong m?i tr??ng n¨¤y.
Thay v¨¤o ?¨®, ch¨²ng t?i khuy¨ºn b?n n¨ºn s? d?ng quan s¨¢t DOM ?? x¨¢c ??nh xem CAPTCHA ?? ???c gi?i quy?t ch?a. V¨ª d?: b?n c¨® th? ki?m tra xem h?p ki?m "T?i kh?ng ph?i l¨¤ ng??i m¨¢y" ?? bi?n m?t hay ?? chuy?n th¨¤nh d?u ki?m (?), cho bi?t qu¨¢ tr¨¬nh x¨¢c th?c ?? ho¨¤n t?t.
H?y c?i thi?n v¨ª d? tr??c b?ng c¨¢ch s? d?ng chi?n l??c n¨¤y:
python
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
# B??c 1: L?y ti?n ¨ªch m? r?ng t? GitHub: https://github.com/capsolver/capsolver-browser-extension/releases
# B??c 2: Gi?i n¨¦n ti?n ¨ªch m? r?ng v¨¤ ??t apiKey c?a b?n trong /assets/config.js
chrome_options.add_argument("load-extension=/path/to/CapSolver Browser Extension-v1.16.0")
# Ch? ??nh ???ng d?n chromedriver (b? qua n?u ?? c¨® trong PATH)
service = Service(executable_path="chromedriver.exe")
driver = webdriver.Chrome(options=chrome_options, service=service)
def check_recaptcha_status(driver):
try:
iframe = driver.find_element(By.CSS_SELECTOR, 'iframe[src*="recaptcha"]')
driver.switch_to.frame(iframe)
# Ki?m tra xem t¨ºn l?p c¨® cho bi?t h?p ki?m ?? ???c ch?n hay kh?ng
recaptcha_anchor = driver.find_element(By.ID, "recaptcha-anchor")
class_list = recaptcha_anchor.get_attribute("class")
driver.switch_to.default_content()
if "recaptcha-checkbox-checked" in class_list.split():
return True
else:
return False
except Exception as e:
print(f"Th?t b?i khi ki?m tra tr?ng th¨¢i reCAPTCHA: {e}")
driver.switch_to.default_content()
return False
try:
driver.get("https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php")
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'form[action="/recaptcha-v2-checkbox.php"]')))
# Ti?n ¨ªch m? r?ng s? t? ??ng nh?n ra v¨¤ gi?i quy?t CAPTCHA.
# Thay v¨¬ ng? m?t th?i gian c? ??nh, h?y ki?m tra ??nh k?.
timeout = 30
start_time = time.time()
while time.time() - start_time < timeout:
if check_recaptcha_status(driver):
print("X¨¢c minh reCAPTCHA th¨¤nh c?ng!")
submit_button = driver.find_element(By.CSS_SELECTOR, 'button[type="submit"]')
submit_button.click()
time.sleep(3)
driver.quit()
break
time.sleep(1)
except Exception as error:
print(error)
finally:
driver.quit()
T¨´y ch?n c?u h¨¬nh manualSolving
Trong c¨¢c v¨ª d? tr??c, qu¨¢ tr¨¬nh gi?i quy?t CAPTCHA b?t ??u t? ??ng ngay sau khi trang ho¨¤n t?t t?i. Tuy nhi¨ºn, trong m?t s? tr??ng h?p, b?n c¨® th? c?n th?c hi?n c¨¢c thao t¨¢c kh¨¢c tr??c¡ªch?ng h?n nh? ?i?n t¨ºn ng??i d¨´ng v¨¤ m?t kh?u¡ªtr??c khi k¨ªch ho?t tr¨¬nh gi?i quy?t CAPTCHA. Vi?c gi?i quy?t CAPTCHA qu¨¢ s?m c¨® th? d?n ??n m? th?ng b¨¢o h?t h?n tr??c khi g?i.
T¨´y ch?n manualSolving
???c thi?t k? ?? gi?i quy?t v?n ?? n¨¤y. B?ng c¨¢ch ??t manualSolving: true
trong /assets/config.js
, b?n c¨® th? t? ??ng k¨ªch ho?t vi?c gi?i quy?t CAPTCHA b?ng m?t trong hai ph??ng ph¨¢p sau:
- M? ph?ng m?t c¨² nh?p chu?t v¨¤o n¨²t ti?n ¨ªch m? r?ng CapSolver th?ng qua Selenium.
- Th?c thi m?t script ?? g?i m?t th?ng b¨¢o:
window.postMessage({ type: 'capsolverSolve' });
(L?u ?: Ph??ng ph¨¢p n¨¤y ???c h? tr? trong c¨¢c phi¨ºn b?n ti?n ¨ªch m? r?ng v1.16.0 tr? l¨ºn.)
V¨ª d? sau ??y minh h?a c¨¢ch s? d?ng c? hai ph??ng ph¨¢p:
python
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
# B??c 1: L?y ti?n ¨ªch m? r?ng t? GitHub (https://github.com/capsolver/capsolver-browser-extension/releases)
# B??c 2: Gi?i n¨¦n ti?n ¨ªch m? r?ng v¨¤ c?u h¨¬nh apiKey c?a b?n trong /assets/config.js
chrome_options.add_argument("load-extension=/path/to/CapSolver Browser Extension-v1.16.0")
# Ch? ??nh ???ng d?n chromedriver (b? qua n?u ?? c¨® trong PATH)
service = Service(executable_path="chromedriver.exe")
driver = webdriver.Chrome(options=chrome_options, service=service)
def check_recaptcha_status(driver):
try:
iframe = driver.find_element(By.CSS_SELECTOR, 'iframe[src*="recaptcha"]')
driver.switch_to.frame(iframe)
# X¨¢c ??nh xem h?p ki?m ?? ???c ch?n hay ch?a
recaptcha_anchor = driver.find_element(By.ID, "recaptcha-anchor")
class_list = recaptcha_anchor.get_attribute("class")
driver.switch_to.default_content()
if "recaptcha-checkbox-checked" in class_list.split():
return True
else:
return False
except Exception as e:
print(f"Th?t b?i khi ki?m tra tr?ng th¨¢i reCAPTCHA: {e}")
driver.switch_to.default_content()
return False
try:
driver.get("https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php")
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'form[action="/recaptcha-v2-checkbox.php"]')))
# M? ph?ng ??u v¨¤o c?a ng??i d¨´ng
driver.execute_script("""
const inputA = document.querySelector('input[name="ex-a"]');
inputA.value = 'username';
const inputB = document.querySelector('input[name="ex-b"]');
inputB.value = 'password';
""")
# M? ph?ng c¨¢c thao t¨¢c b? sung
for i in range(1, 6):
time.sleep(1)
print(f"?? ch? {i} gi?y...")
# K¨ªch ho?t vi?c gi?i quy?t CAPTCHA (manualSolving ph?i ???c ??t th¨¤nh true trong config.js)
print("B?t ??u gi?i quy?t captcha...")
# Ph??ng ph¨¢p 1: M? ph?ng vi?c nh?p v¨¤o n¨²t CapSolver
try:
capsolver_button = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#capsolver-solver-tip-button")))
driver.execute_script("arguments[0].click();", capsolver_button)
except Exception as e:
print(f"Kh?ng t¨¬m th?y n¨²t CapSolver: {e}")
# Ph??ng ph¨¢p 2: K¨ªch ho?t th?ng qua postMessage (ph??ng ph¨¢p thay th?)
# driver.execute_script("window.postMessage({ type: 'capsolverSolve' });")
# Ch? CAPTCHA ???c gi?i quy?t v¨¤ g?i bi?u m?u
timeout = 30
python
start_time = time.time()
while time.time() - start_time < timeout:
if check_recaptcha_status(driver):
print("reCAPTCHA verification successful!")
submit_button = driver.find_element(By.CSS_SELECTOR, 'button[type="submit"]')
submit_button.click()
time.sleep(3)
driver.quit()
break
time.sleep(1)
except Exception as error:
print(error)
finally:
driver.quit()
CapSolver cung c?p SDK ch¨ªnh th?c cho c? Python v¨¤ Golang, cho ph¨¦p b?n t¨ªch h?p gi?i quy?t CAPTCHA v?i n? l?c t?i thi?u. Kh?ng gi?ng nh? vi?c s? d?ng API th? (n?i b?n ph?i t? x? l? createTask
v¨¤ getTaskResult
), c¨¢c SDK ??n gi?n h¨®a to¨¤n b? quy tr¨¬nh.
Kho l?u tr? GitHub ch¨ªnh th?c:
- SDK Python
- SDK Golang
Gi?i quy?t reCAPTCHA v2 v?i SDK CapSolver
C?ng gi?ng nh? v?i API, tr??c khi gi?i quy?t reCAPTCHA v2, b?n n¨ºn tham kh?o t¨¤i li?u ?? bi?t th?ng tin chi ti?t v? c¨¢c tham s? JSON c?n g?i:
? https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/
Ngo¨¤i ra, b?n c¨® th? s? d?ng ti?n ¨ªch m? r?ng tr¨¬nh duy?t CapSolver ?? nhanh ch¨®ng tr¨ªch xu?t d? li?u JSON c?n thi?t:
? /blog/reCAPTCHA/recaptcha-v3-solver-human-score
H?y s? d?ng trang n¨¤y l¨¤m v¨ª d?:
? https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php
D? li?u JSON c?n thi?t tr?ng nh? th? n¨¤y:
json
{
"type": "ReCaptchaV2TaskProxyLess",
"websiteKey": "6LfW6wATAAAAAHLqO2pb8bDBahxlMxNdo9g947u9",
"websiteURL": "https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php"
}
C¨¤i ??t SDK CapSolver:
bash
pip install capsolver
V¨ª d?: S? d?ng SDK trong Selenium
python
import time
import capsolver
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
service = Service(executable_path="chromedriver.exe")
driver = webdriver.Chrome(options=chrome_options, service=service)
# Thi?t l?p c?u h¨¬nh CapSolver c?a b?n
api_key = "YOUR_API_KEY"
site_key = "6LfW6wATAAAAAHLqO2pb8bDBahxlMxNdo9g947u9"
site_url = "https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php"
captcha_type = 'ReCaptchaV2TaskProxyLess'
capsolver.api_key = api_key
try:
# Gi?i quy?t b?ng SDK
solution = capsolver.solve({
"type": captcha_type,
"websiteURL": site_url,
"websiteKey": site_key,
})
token = solution["gRecaptchaResponse"]
print("token:", token)
driver.get(site_url)
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, 'form[action="/recaptcha-v2-checkbox.php"]'))
)
driver.execute_script("""
const textarea = document.getElementById('g-recaptcha-response');
if (textarea) {
textarea.value = arguments[0];
}
""", token)
submit_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[type="submit"]'))
)
submit_button.click()
time.sleep(5)
except Exception as error:
print(error)
finally:
driver.quit()
Gi?i quy?t ImageToText v?i SDK CapSolver
C?ng gi?ng nh? v?i API, ch¨²ng ta s? ti?p t?c v?i trang web:
? https://captcha.com/demos/features/captcha-demo.aspx
H¨¬nh ?nh CAPTCHA c¨® ID demoCaptcha_CaptchaImage
, v¨¤ tr??ng nh?p k?t qu? c¨® ID captchaCode
.
Trong ImageToTextTask
, b?n ch? c?n truy?n h¨¬nh ?nh ???c m? h¨®a base64 cho CapSolver.
M? v¨ª d?:
python
import time
import capsolver
import requests
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
service = Service(executable_path="chromedriver.exe")
driver = webdriver.Chrome(options=chrome_options, service=service)
# Thi?t l?p c?u h¨¬nh CapSolver c?a b?n
api_key = "YOUR_API_KEY"
site_url = "https://captcha.com/demos/features/captcha-demo.aspx"
captcha_type = 'ImageToTextTask'
capsolver.api_key = api_key
try:
driver.get(site_url)
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, '#demoCaptcha_CaptchaImage'))
)
# L?y chu?i base64 t? h¨¬nh ?nh
captcha_src = driver.execute_script("""
const img = document.querySelector('img[id="demoCaptcha_CaptchaImage"]');
return img ? img.getAttribute('src') : null;
""")
if not captcha_src:
raise Exception("Kh?ng th? l?y h¨¬nh ?nh captcha!")
base64_image = captcha_src.split(',')[1]
solution = capsolver.solve({
"type": captcha_type,
"websiteURL": site_url,
"body": base64_image,
})
captcha_text = solution["text"]
print("Text:", captcha_text)
driver.execute_script("""
document.getElementById('captchaCode').value = arguments[0];
""", captcha_text)
validate_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, '#validateCaptchaButton'))
)
validate_button.click()
time.sleep(5)
except Exception as error:
print(error)
finally:
driver.quit()
T¨¤i li?u tham kh?o h?u ¨ªch
- T¨¤i li?u CapSolver
- B?n ph¨¢t h¨¤nh GitHub c?a ti?n ¨ªch m? r?ng CapSolver
- Ti?n ¨ªch m? r?ng CapSolver tr¨ºn Chrome Web Store
- Ti?n ¨ªch m? r?ng CapSolver tr¨ºn Firefox Add-ons
- Tr¨¬nh gi?i ?i?m s? gi?ng ng??i d¨´ng cho reCAPTCHA v3
Video demo c¨® t¨ªnh n?ng ti?n ¨ªch m? r?ng CapSolver:
- Gi?i quy?t reCAPTCHA v3 b?ng ti?n ¨ªch m? r?ng Chrome CapSolver
- Gi?i quy?t reCAPTCHA v2 b?ng ti?n ¨ªch m? r?ng Chrome CapSolver
- Gi?i quy?t reCAPTCHA v?i Puppeteer & ti?n ¨ªch m? r?ng CapSolver
- Gi?i quy?t ImageToText v?i Puppeteer & ti?n ¨ªch m? r?ng CapSolver
Ngo¨¤i ra, CapSolver cung c?p Ch??ng tr¨¬nh chia s? doanh thu cho nh¨¤ ph¨¢t tri?n, cho ph¨¦p c¨¢c nh¨¤ ph¨¢t tri?n v¨¤ ??i t¨¢c ki?m hoa h?ng b?ng c¨¢ch t¨ªch h?p ho?c qu?ng b¨¢ c¨¢c gi?i ph¨¢p CapSolver. ?¨® l¨¤ m?t c¨¢ch tuy?t v?i ?? ki?m ti?n t? c?ng vi?c c?a b?n ??ng th?i gi¨²p ng??i kh¨¢c gi?i quy?t captcha hi?u qu?. ?? bi?t chi ti?t ??y ??, h?y xem:
K? ho?ch d¨¤nh cho nh¨¤ ph¨¢t tri?n CapSolver
K?t lu?n
H??ng d?n n¨¤y ?? ch? cho b?n c¨¢ch t¨ªch h?p hi?u qu? Selenium v?i CapSolver ?? x? l? CAPTCHA. Ch¨²ng t?i ?? ?? c?p ??n c¨¢c t¨ªnh n?ng c?t l?i c?a Selenium ?? t? ??ng h¨®a web v¨¤ l¨¤m n?i b?t hai ph??ng ph¨¢p t¨ªch h?p CapSolver ch¨ªnh:
- Ti?n ¨ªch m? r?ng tr¨¬nh duy?t CapSolver: M?t gi?i ph¨¢p ??n gi?n ?? gi?i quy?t CAPTCHA t? ??ng, r?t ph¨´ h?p cho vi?c thi?t l?p nhanh ch¨®ng.
- API/SDK CapSolver: Cung c?p nhi?u quy?n ki?m so¨¢t v¨¤ ?? ch¨ªnh x¨¢c h?n, l? t??ng cho c¨¢c tr??ng h?p s? d?ng n?ng cao. B?n c¨® th? t¨¬m th?y t¨¤i li?u API chi ti?t ? ??y v¨¤ SDK Python ? ??y.
Tuy¨ºn b? Tu?n th?: Th?ng tin ???c cung c?p tr¨ºn blog n¨¤y ch? mang t¨ªnh ch?t tham kh?o. CapSolver cam k?t tu?n th? t?t c? c¨¢c lu?t v¨¤ quy ??nh hi?n h¨¤nh. Vi?c s? d?ng m?ng l??i CapSolver cho c¨¢c ho?t ??ng b?t h?p ph¨¢p, gian l?n ho?c l?m d?ng l¨¤ ho¨¤n to¨¤n b? c?m v¨¤ s? b? ?i?u tra. C¨¢c gi?i ph¨¢p gi?i captcha c?a ch¨²ng t?i n?ng cao tr?i nghi?m ng??i d¨´ng trong khi ??m b?o tu?n th? 100% trong vi?c gi¨²p gi?i quy?t c¨¢c kh¨® kh?n v? captcha trong qu¨¢ tr¨¬nh thu th?p d? li?u c?ng khai. Ch¨²ng t?i khuy?n kh¨ªch vi?c s? d?ng d?ch v? c?a ch¨²ng t?i m?t c¨¢ch c¨® tr¨¢ch nhi?m. ?? bi?t th¨ºm th?ng tin, vui l¨°ng truy c?p ?i?u kho?n D?ch v? v¨¤ Ch¨ªnh s¨¢ch Quy?n ri¨ºng t?.
Th¨ºm

L¨¤m th? n¨¤o ?? gi?i quy?t m?i phi¨ºn b?n c?a reCAPTCHA Enterprise v2, v2 v? h¨¬nh, v3, v3 Enterprise ?i?m 0.9
N?m v?ng c¨¢ch gi?i quy?t m?i phi¨ºn b?n reCaptcha v?i CapSolver: H??ng d?n n¨¤y cung c?p h??ng d?n t?ng b??c ?? gi?i quy?t reCaptcha m?t c¨¢ch hi?u qu?, ??m b?o k?t qu? ch¨ªnh x¨¢c m?i l?n.

Anh Tuan
11-Oct-2025

L¨¤m th? n¨¤o ?? gi?i CAPTCHA h¨¬nh ?nh
B¨¤i vi?t n¨¤y cung c?p m?t h??ng d?n to¨¤n di?n v? c¨¢ch gi?i captcha h¨¬nh ?nh b?ng CapSolver, m?t c?ng c? ???c thi?t k? ?? t? ??ng h¨®a quy tr¨¬nh. N¨® b?t ??u b?ng vi?c gi?i th¨ªch v? kh¨¢i ni?m captcha h¨¬nh ?nh, sau ?¨® l¨¤ m?t h??ng d?n chi ti?t t?ng b??c v? c¨¢ch s? d?ng API c?a CapSolver ?? gi?i c¨¢c captcha n¨¤y. H??ng d?n bao g?m c¨¢c v¨ª d? v? c¨¢c y¨ºu c?u v¨¤ ph?n h?i li¨ºn quan ??n quy tr¨¬nh. B¨¤i vi?t k?t th¨²c b?ng m?t nh?n x¨¦t v? hi?u qu? v¨¤ ti?n l?i khi s? d?ng CapSolver ?? gi?i captcha h¨¬nh ?nh, l¨¤m cho n¨® tr? th¨¤nh m?t ngu?n t¨¤i nguy¨ºn qu? gi¨¢ cho nh?ng ng??i mu?n t? ??ng h¨®a c¨¢c nhi?m v? li¨ºn quan ??n vi?c gi?i captcha.

Anh Tuan
11-Oct-2025

Gi?i reCaptcha v2 Enterprise
Trong th? gi?i s?, an ninh v¨¤ s? ti?n l?i cho ng??i d¨´ng th??ng ? hai ??u m¨²t ??i l?p c?a thang ?o. CAPTCHAs, ??c bi?t l¨¤ reCaptcha, ?? ?¨®ng vai tr¨° thi?t y?u trong vi?c t¨¬m ra s? c?n b?ng gi?a hai y?u t? n¨¤y. Tuy nhi¨ºn, n?u b?n c?n gi?i quy?t c¨¢c b¨¤i ki?m tra reCaptcha th??ng ph?c t?p v¨¤ t?n th?i gian, ??c bi?t l¨¤ reCaptcha V2 Enterprise, v¨¬ m?t m?c ?¨ªch h?p ph¨¢p nh? ki?m th? t? ??ng th¨¬ sao? Trong b¨¤i vi?t n¨¤y, ch¨²ng t?i s? h??ng d?n b?n qua quy tr¨¬nh gi?i reCaptcha V2 Enterprise b?ng API c?a CapSolver.

Anh Tuan
11-Oct-2025

Gi?i reCaptcha v3
H?c c¨¢ch gi?i reCaptcha V3 b?ng CapSolver: nhi?u lo?i nhi?m v?, t¨ªch h?p API ??n gi?n v¨¤ c¨¢c gi?i ph¨¢p hi?u qu? cho t? ??ng h¨®a v¨¤ ki?m th?

Anh Tuan
10-Oct-2025

C¨¢i n¨¤o l¨¤ gi?i ph¨¢p AWS WAF t?t nh?t trong khi qu¨¦t web v¨¤o n?m 2025?
H?c c¨¢ch gi?i quy?t CAPTCHA AWS WAF hi?u qu? b?ng CapSolver v¨¤o n?m 2025. H??ng d?n t?ng b??c, t¨ªch h?p Python, c?ng c? AI ?? t?ng t?c quy tr¨¬nh t? ??ng h¨®a c?a b?n. V??t qua c¨¢c token ??ng, ph?n t¨ªch h¨¤nh vi v¨¤ c¨¢c th¨¢ch th?c CAPTCHA ph?c t?p m?t c¨¢ch d? d¨¤ng.

Lucas Mitchell
26-Sep-2025

C¨¢ch gi?i quy?t reCaptcha v3 Enterprise
H?c c¨¢ch gi?i quy?t reCAPTCHA v3 Enterprise m?t c¨¢ch d? d¨¤ng b?ng Capsolver: ch¨¬a kh¨®a c?a b?n ?? v??t qua CAPTCHA ph?c t?p v?i ph?n t¨ªch r?i ro n?ng cao v¨¤ t¨ªch h?p li?n m?ch

Anh Tuan
24-Sep-2025