captchago

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 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
  • Get Balance

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 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) String

func (p *Proxy) String() string

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{}
}

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 int

	// 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) 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) 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