captchago

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

README

CaptchaGO

Easily integrate and support many captcha services in your Go project.

View usage examples

Installation

go get github.com/median/captchago

Supported Services

Methods

  • Recaptcha V2
  • Recaptcha V3
  • HCaptcha
  • FunCaptcha
  • Kasada Anti-Bot (CapSolver only)
  • Get Balance

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudflareOptions added in v1.2.0

type CloudflareOptions struct {
	PageURL string
	Proxy   *Proxy

	// SiteKey is only used for CloudflareTypeTurnstile
	SiteKey string

	// Type must only be CloudflareTypeTurnstile if the solver is not capsolver.com
	Type CloudflareType

	// Metadata will only be used on capsolver.com, for any other solver it will just append the fields
	Metadata map[string]string

	// Action and CData are only used for turnstile. CData is only used for 2captcha and capsolver.com
	Action string
	CData  string

	// HTML is only needed for cloudflare challenges
	HTML string
}

CloudflareOptions cloudflare challenges only work with capsolver.com, turnstile works with other solvers

type CloudflareType added in v1.2.0

type CloudflareType int
const (
	CloudflareTypeTurnstile CloudflareType = iota
	CloudflareTypeChallenge
)

type FunCaptchaOptions

type FunCaptchaOptions struct {
	PageURL   string
	PublicKey string

	// Subdomain also known as surl is optional
	Subdomain string

	// Proxy is optional but recommended
	Proxy *Proxy

	// UserAgent is required
	UserAgent string

	// Data is the extra data. Can look like: {"\blob\":\"HERE_COMES_THE_blob_VALUE\"}
	Data string
}

type HCaptchaEnterprise

type HCaptchaEnterprise struct {
	RQData      string
	Sentry      bool
	APIEndpoint string
	Endpoint    string
	ReportAPI   string
	AssetHost   string
	ImgHost     string
}

HCaptchaEnterprise Not every captcha service supports every field here

type HCaptchaOptions

type HCaptchaOptions struct {
	PageURL           string
	SiteKey           string
	UserAgent         string
	Invisible         bool
	Proxy             *Proxy
	EnterprisePayload *HCaptchaEnterprise
}

type KasadaOptions added in v1.1.0

type KasadaOptions struct {
	PageURL string

	// Proxy is required
	Proxy *Proxy

	// DetailedCD Enable if you need more detailed x-kpsdk-cd, including params such as duration, st and rst
	DetailedCD bool

	// OnlyCD Enable if the solution contains only x-kpsdk-cd
	OnlyCD bool

	// Version Currently supports 2.0 and 3.0, default is 3.0
	Version string

	// UserAgent Browser's User-Agent which is used in emulation. Default is random
	UserAgent string
}

KasadaOptions Make sure to set the proxy as its required

type KasadaSolution added in v1.1.0

type KasadaSolution struct {
	*Solution

	// KpsdkCT is the 'x-kpsdk-ct' header
	KpsdkCT string

	// KpsdkCD is the 'x-kpsdk-cd' header
	KpsdkCD string

	// UserAgent is the user agent used to solve the captcha
	UserAgent string
}

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(t ProxyType, address string, port int, login *ProxyLogon) *Proxy

func ParseProxy

func ParseProxy(proxyUrl string) (*Proxy, error)

func (*Proxy) FullString added in v1.1.2

func (p *Proxy) FullString() string

FullString returns the proxy address, port and type

func (*Proxy) String

func (p *Proxy) String() string

String only returns the proxy address and port

type ProxyLogon

type ProxyLogon struct {
	Username string
	Password string
}

func (*ProxyLogon) String

func (pl *ProxyLogon) String() string

type ProxyType

type ProxyType = string
const (
	ProxyTypeHTTP   ProxyType = "http"
	ProxyTypeHTTPS  ProxyType = "https"
	ProxyTypeSOCKS4 ProxyType = "socks4"
	ProxyTypeSOCKS5 ProxyType = "socks5"
)

type RecaptchaV2Options

type RecaptchaV2Options struct {
	// SiteKey is the site key of the recaptcha
	SiteKey string
	// PageURL is the URL of the page where the reCAPTCHA is located
	PageURL string
	// DataS is the data-s attribute of the reCAPTCHA element (optional)
	DataS string
	// Proxy is the proxy to use for the captcha (optional)
	Proxy *Proxy
	// UserAgent is the user agent to use for the captcha (optional)
	UserAgent string
	// Cookies is the cookies to use for the captcha (optional)
	Cookies map[string]string
	// Invisible is whether the captcha is invisible or not (optional)
	Invisible bool
	// Enterprise only works on some captcha services (optional)
	Enterprise map[string]interface{}
	// APIDomain is the domain of the recaptcha (optional)
	APIDomain string
}

type RecaptchaV3Options

type RecaptchaV3Options struct {
	PageURL    string
	SiteKey    string
	Enterprise bool

	// MinScore should only be 0.3, 0.7, or 0.9
	MinScore float64

	// Action is the page_action in the requests
	Action string
}

RecaptchaV3Options All fields are required

type Solution

type Solution struct {
	Text string

	// TaskId is normally a int, but can be a string depending on the service
	TaskId any

	// RawSolution not supported on 2captcha methods
	RawSolution map[string]interface{}

	// Speed the time in milliseconds that the captcha took to solve
	Speed int64

	// Cookies can be nil or empty if the service does not return cookies
	Cookies map[string]string

	// Cost can be "" if the service does not return cost
	Cost string

	// IP can be "" if the service does not return IP
	IP string
}

type SolveService

type SolveService = string
const (
	AntiCaptcha SolveService = "anticaptcha"
	AnyCaptcha  SolveService = "anycaptcha"
	CapSolver   SolveService = "capsolver"
	TwoCaptcha  SolveService = "2captcha"
	CapMonster  SolveService = "capmonster"
)

type Solver

type Solver struct {
	// UpdateDelay is the delay between each update getTaskResult request
	UpdateDelay time.Duration

	// Disabling Verbose will disable all logging
	Verbose bool

	// ApiKey is the key used to authenticate with the service
	ApiKey string

	// ForcedDomain don't edit unless you know what you're doing.
	// This is used to allow the user to change their captcha service to whatever
	// they want as long as they share the same api methods.
	ForcedDomain string
	// contains filtered or unexported fields
}

func New

func New(service SolveService, apiKey string) (*Solver, error)

func (*Solver) Cloudflare added in v1.2.0

func (s *Solver) Cloudflare(o CloudflareOptions) (*Solution, error)

func (*Solver) FunCaptcha

func (s *Solver) FunCaptcha(o FunCaptchaOptions) (*Solution, error)

func (*Solver) GetBalance

func (s *Solver) GetBalance() (float64, error)

GetBalance returns the balance of the account

func (*Solver) GetService

func (s *Solver) GetService() SolveService

func (*Solver) HCaptcha

func (s *Solver) HCaptcha(o HCaptchaOptions) (*Solution, error)

func (*Solver) IsValidService added in v1.0.0

func (s *Solver) IsValidService(service SolveService) bool

func (*Solver) Kasada added in v1.1.0

func (s *Solver) Kasada(o KasadaOptions) (*KasadaSolution, error)

Kasada is only supported with capsolver.com

func (*Solver) RecaptchaV2

func (s *Solver) RecaptchaV2(o RecaptchaV2Options) (*Solution, error)

RecaptchaV2 solves a recaptcha v2

func (*Solver) RecaptchaV3

func (s *Solver) RecaptchaV3(o RecaptchaV3Options) (*Solution, error)

func (*Solver) SetService

func (s *Solver) SetService(service SolveService) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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