twocaptcha

package module
v0.0.0-...-47013e7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: MIT Imports: 8 Imported by: 0

README

twocaptcha

Package for serving captcha solutions from the 2captcha API.
Supported Captcha Types: RecaptchaV2, RecaptchaV3, Funcaptcha, hCaptcha

Fixed Solver: Solve a fixed number of captchas with an optional task multiplier for avoiding hanging tasks.
Persistent Solver: Keep solving captchas using the designated number of threads until channels are closed.
* Note for persistent solving: closing either the solutions or errors channel cancels the solving runtime.
* General Note: mostly untested because of schoolwork, please create issues with any errors or whatnot that occur!

Install

go get -u "https://github.com/braised-pork/twocaptcha"

Usage (Fixed)

// Initialize the solving instance (api key, threads, total, multiplier, enable errors channel)
fixedSolver, ok := twocaptcha.NewFixedSolver("insert_api_key_here", 100, 1000, 1.1, false)
if !ok {
  // provided API key is invalid, do something
}

// Set the type of captcha to solve, with parameters
fixedSolver.SetRecaptchaV2("insert_sitekey_here", "insert_siteurl_here")

go fixedSolver.SolvingRuntime() // begin solving routine

for solution := range fixedSolver.Channels.Solved {
  // do something with captcha solution
}

Usage (Persistent)

// Initialize the solving instance (api key, threads, enable errors channel)
persistentSolver, ok := twocaptcha.NewPersistentSolver("insert_api_key_here", 100, false)
if !ok {
  // provided API key is invalid, do something
}

// Set the type of captcha to solve, with parameters
persistentSolver.SetRecaptchaV2("insert_sitekey_here", "insert_siteurl_here")

go persistentSolver.SolvingRuntime() // begin solving routine

for solution := range persistentSolver.Channels.Solved {
  // do something with captcha solution
}

// [in an alternate goroutine ...]

close(persistentSolver.Channels.Solved) // close when you've had enough

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channels

type Channels struct {
	Solved chan string // captcha solutions
	Errors chan error  // any encountered errors
}

type Solver

type Solver struct {
	// should I un-export fields?
	Channels
	Threads       int     // 1/2) solving threads
	TotalCaptchas int     // 1) captchas desired
	Multiplier    float64 // 1) solving multiplier, init at 1!
	// contains filtered or unexported fields
}

TODO find more elegant way to create multiple solving instances from one config? TODO break into different chunks for mix-and-match Solver stores parameters and statistics for the current session

func NewFixedSolver

func NewFixedSolver(apiKey string, threads int, totalCaptchas int, multiplier float64, errEnable bool) (solver *Solver, ok bool)

NewFixedSolver returns a Solver instance which solves a fixed number of captchas of a given type.

func NewPersistentSolver

func NewPersistentSolver(apiKey string, threads int, errEnable bool) (solver *Solver, ok bool)

NewPersistentSolver returns a Solver instance which continuously solves captchas until the output channel is closed.

func (*Solver) SetFuncaptcha

func (solver *Solver) SetFuncaptcha(siteKey string, sURL string, siteURL string)

SetFuncaptcha sets the URL for solving the designated Funcaptcha.

func (*Solver) SetRecaptchaV2

func (solver *Solver) SetRecaptchaV2(siteKey string, siteURL string)

SetRecaptchaV2 sets the URL for solving the designated RecaptchaV2.

func (*Solver) SetRecaptchaV3

func (solver *Solver) SetRecaptchaV3(siteKey string, siteURL string, action string, minScore string)

SetRecaptchaV3 sets the URL for solving the designated RecaptchaV3.

func (*Solver) SethCaptcha

func (solver *Solver) SethCaptcha(siteKey string, siteURL string)

SethCaptcha sets the URL for solving the designated hCaptcha.

func (*Solver) SolvingRuntime

func (solver *Solver) SolvingRuntime()

solvingRuntime manages the threads which solve captchas and closes channels if necessary. TODO maybe return analytics from the function?

Jump to

Keyboard shortcuts

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