The easiest way to quickly integrate [2Captcha] into your code.
To install the api client, use this:
go get -u github.com/kpabellan/2captcha-go
Import the module like this:
import (
"github.com/kpabellan/2captcha-go"
)
Client
instance can be created like this:
client := api2captcha.NewClient("YOUR_API_KEY")
There are few options that can be configured:
client.RecaptchaTimeout = 600
client.PollingInterval = 10
Option | Default value | Description |
---|---|---|
recaptcha_timeout | 600 | Timeout for ReCaptcha in seconds. Defines how long the module tries to get the answer from res.php API endpoint |
polling_interval | 10 | Interval in seconds between requests to res.php API endpoint, setting values less than 5 seconds is not recommended |
Use this method to solve ReCaptcha V2 and obtain a token to bypass the protection.
cap := api2captcha.ReCaptcha{
SiteKey: "6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-",
Url: "https://mysite.com/page/with/recaptcha",
Invisible: true,
Action: "verify",
}
req := cap.ToRequest()
req.SetProxy("HTTPS", "login:password@IP_address:PORT")
code, err := client.solve(req)
This method provides ReCaptcha V3 solver and returns a token.
cap := api2captcha.ReCaptcha{
SiteKey: "6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-",
Url: "https://mysite.com/page/with/recaptcha",
Version: "v3",
Action: "verify",
Score: 0.3,
}
req := cap.ToRequest()
req.SetProxy("HTTPS", "login:password@IP_address:PORT")
code, err := client.solve(req)
Use this method to get your account's balance
balance, err := client.GetBalance()
if err != nil {
log.Fatal(err);
}