2captcha-haskell
The easiest way to integrate 2captcha into your application to automate common types of captchas.
Table of Contents
Solving a captcha
Solving a captcha using 2captcha's api is through the in.php
and res.php
endpoints.
This package encapsulates the mentioned endpoints through submit and answer.
If you'd like to poll for the answer, use solve.
Default timeout: 120 seconds.
ReCAPTCHA timeout: 600 seconds.
Polling interval: 10 seconds
Below are the minimal required parameters to solve each type of captcha.
Normal Captcha
This function can be used to solve a local image captcha.
let captcha =
normalCaptcha
& apiKey ?~ "YOUR_API_KEY"
& method ?~ "post"
& file ?~ "/path/to/file"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
This function can be used to solve a captcha encoded in base-64 form.
let captcha =
normalCaptcha
& apiKey ?~ "YOUR_API_KEY"
& method ?~ "base64"
& body ?~ "BASE_64_ENCODED_IMAGE"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
Text Captcha
This function can be used to solve captchas in text form.
let captcha =
textCaptcha
& apiKey ?~ "YOUR_API_KEY"
& textContent ?~ "If tomorrow is Saturday, what day is it today?"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
ReCAPTCHA v2
ReCAPTCHA v2 requires a k
or data-sitekey
value found on the captcha page.
let captcha =
reCAPTCHAV2
& apiKey ?~ "YOUR_API_KEY"
& googleKey ?~ "GOOGLE_KEY_VALUE"
& pageUrl ?~ "PAGE_URL"
session <- newAPISession
solve session captcha pollingInterval reCAPTCHATimeout
ReCaptcha v3
ReCAPTCHA v3 requires a k
or data-sitekey
value found on the captcha page.
let captcha =
reCAPTCHAV3
& apiKey ?~ "YOUR_API_KEY"
& googleKey ?~ "GOOGLE_KEY_VALUE"
& pageUrl ?~ "PAGE_URL"
session <- newAPISession
solve session captcha pollingInterval reCAPTCHATimeout
FunCaptcha
FunCaptcha (ArkoseLabs) requires a pk
or data-pkey
value found on the captcha page.
let captcha =
funCaptcha
& apiKey ?~ "YOUR_API_KEY"
& publicKey ?~ "PUBLIC_KEY"
& pageUrl ?~ "PAGE_URL"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
GeeTest
GeeTest requires the gt
, challenge
, and api_server
values on the captcha page.
let captcha =
geeTestCaptcha
& apiKey ?~ "YOUR_API_KEY"
& gt ?~ "GT_VALUE"
& apiServer ?~ "API_SERVER"
& challenge ?~ "CAPTCHA_CHALLENGE"
& pageUrl ?~ "PAGE_URL"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
hCaptcha
hCaptcha requires the data-sitekey
value on the captcha page.
let captcha =
hCaptcha
& apiKey ?~ "YOUR_API_KEY"
& siteKey ?~ "SITE_KEY"
& pageUrl ?~ "PAGE_URL"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
KeyCaptcha
KeyCaptcha requires the s_s_c_user_id
, s_s_c_session_id
, s_s_c_web_server_sign
, and s_s_c_web_server_sign2
values on the captcha page.
let captcha =
keyCaptcha
& apiKey ?~ "YOUR_API_KEY"
& userId ?~ "USER_ID_VALUE"
& sessionId ?~ "SESSION_ID_VALUE"
& webServerSign ?~ "WEB_SERVER_SIGN_VALUE"
& webServerSign2 ?~ "WEB_SERVER_SIGN_2_VALUE"
& pageUrl ?~ "PAGE_URL"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
Capy
Capy requires the captchakey
value on the captcha page.
let captcha =
capyCaptcha
& apiKey ?~ "YOUR_API_KEY"
& captchaKey ?~ "CAPTCHA_KEY"
& pageUrl ?~ "PAGE_URL"
& scriptDomain ?~ "SCRIPT_DOMAIN"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
Grid
This function can be used to solve a local grid image captcha.
let captcha =
gridCaptcha
& apiKey ?~ "YOUR_API_KEY"
& method ?~ "post"
& file ?~ "/path/to/file"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
Coordinate
This function can be used to solve a local coordinate image captcha.
let captcha =
coordinateCaptcha
& apiKey ?~ "YOUR_API_KEY"
& method ?~ "post"
& file ?~ "/path/to/file"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
Rotate
This function can be used to solve a local rotate image captcha.
let captcha =
rotateCaptcha
& apiKey ?~ "YOUR_API_KEY"
& file ?~ "/path/to/file"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout
TikTok
TikTok requires the aid
and host
values on the captcha page.
let captcha =
tikTokCaptcha
& apiKey ?~ "YOUR_API_KEY"
& cookies ?~ "YOUR_COOKIES"
& aid ?~ 0
& host ?~ "HOST_VALUE"
& pageUrl ?~ "PAGE_URL"
session <- newAPISession
solve session captcha pollingInterval captchaTimeout