captcha

package
v0.0.0-...-4366327 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCaptchaNotFound = errors.New("elementos do captcha não encontrados")
View Source
var ErrCaptchaTimeout = errors.New("timeout aguardando resolução do captcha")

Functions

func AngleToPixels

func AngleToPixels(angleDeg float32, trackWidth, knobWidth float64) float64

AngleToPixels converte um ângulo (em graus, range -180 a 180) para a distância em pixels que o slider deve ser arrastado.

Normaliza o ângulo para o espectro positivo [0, 360) usando math.Mod e calcula:

pixels = (ângulo / 360) × (trackWidth - knobWidth)

func DownloadImageAsBase64

func DownloadImageAsBase64(imageURL string) (string, error)

func DownloadImageBytes

func DownloadImageBytes(url string) ([]byte, error)

DownloadImageBytes baixa uma imagem por URL e retorna os bytes crus.

func DownloadImageRaw

func DownloadImageRaw(imageURL string) ([]byte, error)

DownloadImageRaw baixa uma imagem por URL e retorna os bytes crus. Trata data URIs extraindo e decodificando o base64 embutido.

func ExtractRotateImageBytes

func ExtractRotateImageBytes(page *rod.Page) (outer, inner []byte, err error)

ExtractRotateImageBytes extrai as imagens do captcha de rotação como bytes crus. Retorna os binários das imagens (PNG/JPEG/WebP) prontos para inferência ONNX.

func ExtractRotateImages

func ExtractRotateImages(page *rod.Page) (outer, inner string, err error)

ExtractRotateImages extrai as imagens do captcha de rotação em Base64. Mantido para compatibilidade com fallbacks (NATS, SadCaptcha).

func IsCaptchaPresent

func IsCaptchaPresent(page *rod.Page) bool

IsCaptchaPresent verifica se um captcha está presente na página de forma não-bloqueante.

func RunShadowCollector

func RunShadowCollector(page *rod.Page, datasetPath string, origin string) error

RunShadowCollector executa o fluxo completo do Shadow Collector para extração

Types

type RotationLabel

type RotationLabel struct {
	ID            string  `json:"id"`
	Angle         float64 `json:"angle"`
	RawPixels     float64 `json:"raw_pixels"`
	SlidebarWidth float64 `json:"slidebar_width"`
	IconWidth     float64 `json:"icon_width"`
	Timestamp     string  `json:"timestamp"`
}

RotationLabel é o JSON final salvo para cada sample de treinamento.

type Solver

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

Solver executa inferência ONNX para resolver captchas de rotação. Thread-safe: pode ser chamado de múltiplas goroutines.

func NewSolver

func NewSolver(modelPath string, sharedLibPath string) (*Solver, error)

NewSolver inicializa o ONNX Runtime e cria uma sessão com o modelo. modelPath é o caminho absoluto para o arquivo .onnx. sharedLibPath é o caminho para libonnxruntime.so (pode ser "" para usar o default).

func (*Solver) Close

func (s *Solver) Close() error

Close libera os recursos do solver e do ONNX Runtime.

func (*Solver) Predict

func (s *Solver) Predict(outerB64, innerB64 string) (float32, error)

Predict recebe as imagens outer e inner como strings base64 (sem prefixo data:) e retorna o ângulo previsto em graus. Decodifica para bytes e delega a PredictBytes.

func (*Solver) PredictBytes

func (s *Solver) PredictBytes(outerRaw, innerRaw []byte) (float32, error)

PredictBytes recebe as imagens outer e inner como bytes crus (PNG/JPEG/WebP) e retorna o ângulo previsto em graus. Este é o método primário de inferência.

Jump to

Keyboard shortcuts

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