crapsolver

package
v0.0.0-...-f1d59ab Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"
)

Variables

View Source
var (
	TASKTYPE_ENTERPRISE = 0
	TASKTYPE_NORMAL     = 1
)
View Source
var (
	STATUS_SOLVING = 0
	STATUS_SOLVED  = 1
	STATUS_ERROR   = 2
)
View Source
var (
	Nodes = GoCycle.New(&[]string{
		"http://127.0.0.1:80",
		"http://127.0.0.1:80",
	})
)

Functions

func RemoveNode

func RemoveNode(url string) error

delete node address

Types

type CheckResponse

type CheckResponse struct {
	Data struct {
		Error      string `json:"error"`
		Expiration int    `json:"expiration"`
		ID         string `json:"id"`
		Status     int    `json:"status"`
		Success    bool   `json:"success"`
		Token      string `json:"token"`
		UserAgent  string `json:"user_agent"`
		Req        string `json:"req"`
	} `json:"data"`
	Message string `json:"message"`
	Status  string `json:"status"`
}

type CheckRestrictionResp

type CheckRestrictionResp struct {
	Success bool         `json:"success"`
	Data    Restrictions `json:"data"`
}

type GetUserResp

type GetUserResp struct {
	Data struct {
		Error                 string `json:"error"`
		Balance               string `json:"balance"`
		ApiKey                string `json:"id"`
		SolvedHcaptcha        int    `json:"solved_hcaptcha"`
		ThreadUsedHcaptcha    int    `json:"thread_used_hcaptcha"`
		ThreadMaxHcaptcha     int    `json:"thread_max_hcaptcha"`
		BypassRestrictedSites bool   `json:"bypass_restricted_sites"`
	} `json:"data"`
	Success bool `json:"success"`
}

func GetUser

func GetUser(uid string) (*GetUserResp, error)

type Restrictions

type Restrictions struct {
	// Minimum turbo submit time
	MinSubmitTime int

	// Maximum turbo submit time
	MaxSubmitTime int

	// Domain associated to the site-key
	Domain string

	// If 'a11y_tfe' must be enabled
	AlwaysText bool

	// If 'oneclick_only' must be enabled
	OneclickOnly bool

	// If the site-key is enabled
	Enabled bool

	// Price / 1000 captchas
	Rate float64
}

func GetRestrictions

func GetRestrictions(sitekey string) (*Restrictions, error)

Get restriction for a specific site-keys

type Solver

type Solver struct {
	Client   *fasthttp.Client
	WaitTime time.Duration

	ApiKey string
}

func NewSolver

func NewSolver(apiKey string, nodeList ...string) (*Solver, error)

func (*Solver) GetResult

func (S *Solver) GetResult(T *TaskResponse, Server string) (resp *CheckResponse, err error)

Get captcha task result

func (*Solver) NewTask

func (S *Solver) NewTask(config *TaskConfig, Server string) (resp *TaskResponse, err error)

Create captcha task

func (*Solver) SetWaitTime

func (S *Solver) SetWaitTime(t time.Duration) error

Edit the delay between check task result

func (*Solver) Solve

func (S *Solver) Solve(config *TaskConfig) (*CheckResponse, error)

Solve captcha and raise error if can't solve

func (*Solver) SolveUntil

func (S *Solver) SolveUntil(config *TaskConfig, retry ...int) (*CheckResponse, error)

Attempt to solve a captcha indefinitely until success, leave the "retry" parameter at 0 to solve indefinitely, modify it to stop if X errors occur and return a list of errors.

type TaskConfig

type TaskConfig struct {
	// @domain (str, required): The domain where the captcha is presented.
	Domain string `json:"domain"`

	// @sitekey (str, required): The sitekey associated with the captcha.
	SiteKey string `json:"site_key"`

	// @useragent (str, optional): The user agent to use when making requests.
	// -> Defaults to a common user agent string.
	UserAgent string `json:"user_agent"`

	// @proxy (str, required): The proxy to use for making requests.
	Proxy string `json:"proxy"`

	// @task_type (TASK_TYPE, optional): The type of captcha-solving task.
	// -> Defaults to TASK_TYPE.TYPE_NORMAL.
	TaskType int `json:"task_type"`

	// @invisible (bool, optional): Whether the captcha is invisible.
	// -> Defaults to False.
	Invisible bool `json:"invisible"`

	// @rqdata (str, optional): Additional request data.
	// -> Defaults to an empty string.
	Rqdata string `json:"rqdata"`

	// @text_free_entry (bool, optional): Whether free text entry is allowed.
	// -> Defaults to False.
	A11YTfe bool `json:"a11y_tfe"`

	// @turbo (bool, optional): Whether turbo mode is enabled.
	// -> Defaults to False.
	Turbo bool `json:"turbo"`

	// @turbo_st (int, optional): The turbo mode submit time in milliseconds.
	// -> Defaults to 3000 (3s).
	TurboSt int `json:"turbo_st"`

	// @hc_accessibility (string, optional): hc_accessibility cookie, instant pass normal website.
	HcAccessibility string `json:"hc_accessibility"`

	// @oneclick_only (bool, optional): If captcha images spawn, task will be stopped and error returned.
	OneclickOnly bool `json:"oneclick_only"`

	// @href (string, optional): href of the actual page where the captcha spawn, get it via motionData.
	// Defaults to https://domain.
	Href string `json:"href"`

	// @exec (bool, optional): Params you can gather via motionData
	Exec bool `json:"exec"`

	// @dr (string, optional): Params you can gather via motionData
	Dr string `json:"dr"`
}

type TaskDataResponse

type TaskDataResponse struct {
	ID         string `json:"id"`
	Status     int    `json:"status"`
	Token      string `json:"token"`
	Error      string `json:"error"`
	Success    bool   `json:"success"`
	Expiration int    `json:"expiration"`
}

type TaskResponse

type TaskResponse struct {
	Data    []TaskDataResponse `json:"data,omitempty"`
	Message string             `json:"message"`
	Success bool               `json:"success"`
}

Jump to

Keyboard shortcuts

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