capsolver_go

package module
v0.0.0-...-6ddd734 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2025 License: BSD-2-Clause Imports: 9 Imported by: 1

README

Capsolver

CapSolver official go library

Supported CAPTCHA types:

  • Geetest
  • ReCaptchaV2
  • ReCaptchav3
  • Cloudflare

Installation

You don't need this source code unless you want to modify the package. If you just want to use the package, just run:

go get github.com/capsolver/capsolver-go

Usage

export CAPSOLVER_API_KEY='...'

Or set capsolver apiKey to its value:

 capSolver := CapSolver{}
 //capSolver := CapSolver{apiKey:"..."} 
 s, err := capSolver.Solve(
            map[string]any{
            "type":       "ReCaptchaV2taskProxyLess",
            "websiteURL": "https://www.google.com/recaptcha/api2/demo",
            "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
 })
 if err != nil {
    log.Fatal(err)
 }
 log.Println(s.Solution.GRecaptchaResponse)
	

 // recognition 
 b, err := os.ReadFile("queue-it.jpg")
 if err != nil {
    panic(err)
 }
 s, err := capSolver.Solve(
    map[string]any{
	"type": "ImageToTextTask",
        "module": "queueit",
        "body":   base64.StdEncoding.EncodeToString(b),
 })
 if err != nil {
    log.Fatal(err)
 }
 log.Println(s.Solution.Text)
		
  // get balance 
  b, err := capSolver.Balance()
  if err != nil {
    log.Fatal(err)
  }
  log.Println(b.Balance)

Documentation

Index

Constants

View Source
const (
	STATUS_READY    = "ready"
	CREATE_TASK_URI = "/createTask"
	GET_TASK_URI    = "/getTaskResult"
	BALANCE_URI     = "/getBalance"
	TASK_TIMEOUT    = 45
)

Variables

View Source
var (
	ApiKey  = os.Getenv("CAPSOLVER_API_KEY")
	ApiHost = os.Getenv("CAPSOLVER_API_HOST")
)
View Source
var (
	SUPPORT_CAPTCHA_TYPES = []string{

		"HCaptchaTask",
		"HCaptchaTaskProxyLess",
		"HCaptchaEnterpriseTask",
		"HCaptchaEnterpriseTaskProxyLess",
		"HCaptchaTurboTask",

		"FunCaptchaTask",
		"FunCaptchaTaskProxyLess",

		"GeeTestTask",
		"GeeTestTaskProxyLess",

		"ReCaptchaV2Task",
		"ReCaptchaV2TaskProxyLess",

		"ReCaptchaV2EnterpriseTaskProxyLess",
		"ReCaptchaV2EnterpriseTask",

		"ReCaptchaV3Task",
		"ReCaptchaV3TaskProxyLess",

		"ReCaptchaV3EnterpriseTask",
		"ReCaptchaV3EnterpriseTaskProxyLess",

		"MtCaptchaTask",
		"MtCaptchaTaskProxyLess",

		"DataDomeSliderTask",

		"AntiCloudflareTask",

		"AntiKasadaTask",

		"AntiAkamaiBMPTask",

		"ImageToTextTask",

		"HCaptchaClassification",

		"FunCaptchaClassification",

		"AwsWafClassification",
	}
)

Functions

This section is empty.

Types

type CapSolver

type CapSolver struct {
	ApiKey string
}

func (CapSolver) Balance

func (c CapSolver) Balance() (*capSolverResponse, error)

func (CapSolver) Solve

func (c CapSolver) Solve(task map[string]any) (*capSolverResponse, error)

type CapSolverTask

type CapSolverTask struct {
	Type                      string             `json:"type"`
	WebsiteURL                string             `json:"websiteURL,omitempty"`
	WebsiteKey                string             `json:"websiteKey,omitempty"`
	Proxy                     string             `json:"proxy,omitempty"`
	EnterPrisePayload         *enterPrisePayload `json:"enterprisePayload,omitempty"`
	IsInvisible               bool               `json:"isInvisible,omitempty"`
	ApiDomain                 string             `json:"apiDomain,omitempty"`
	UserAgent                 string             `json:"userAgent,omitempty"`
	Cookies                   *cookies           `json:"cookies,omitempty"`
	Module                    string             `json:"module,omitempty"`
	Body                      string             `json:"body,omitempty"`
	Question                  string             `json:"question,omitempty"`
	Queries                   []string           `json:"Queries,omitempty"`
	PageAction                string             `json:"pageAction,omitempty"`
	MinScore                  float32            `json:"MinScore,omitempty"`
	Gt                        string             `json:"gt,omitempty"`
	Challenge                 string             `json:"challenge,omitempty"`
	GeetestApiServerSubdomain string             `json:"geetestApiServerSubdomain,omitempty"`
	CaptchaId                 string             `json:"captchaId,omitempty"`
	CaptchaUrl                string             `json:"captchaUrl,omitempty"`
	Metadata                  map[string]string  `json:"metadata"`
	Html                      string             `json:"html"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL