urldiff

package module
v0.0.0-...-f65b8a5 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2019 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	NotEqualURLsCode int = iota + 1000

	HTTPStatusChangedCode
	HTTPBodyLengthChangedCode

	ImageHashThresholdTriggeredCode
	HTTPBodyHashThresholdTriggeredCode
)

Compare error codes.

View Source
const (
	NotEqualURLsMessage = "left URL is different from right URL"

	HTTPStatusChangedMessage = "HTTP status code differs"

	HTTPBodyLengthChangedMessage          = "HTTP body length differs significantly"
	ImageHashThresholdTriggeredMessage    = "URL screenshot difference hash threshold triggered"
	HTTPBodyHashThresholdTriggeredMessage = "HTTP body fuzzy hash threshold triggered"
)

Compare error messages.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// CDPPath path to CDP binary
	CDPPath string

	// DeadLine global deadline for URL processing
	DeadLine int
	// WaitTime defines time for URL stabilization
	WaitTime int

	// ImageWidth defines CDP viewport width
	ImageWidth int
	// ImageHight defines CDP viewport hight
	ImageHight int

	// BodyLengthThresholdPercentage defines threshold score (percentage) above which difference (for HTML body length) will be reported
	BodyLengthThresholdPercentage int
	// FuzzyThreshold defines threshold score (number) above which difference (for HTML) will be reported
	FuzzyThreshold int
	// ImageDistanceThreshold defines threshold score (number) above which difference (for Iamge) will be reported
	ImageDistanceThreshold int
	// http Client used to get URL Info
	Client *http.Client
}

Config is a configration object for this library.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default config object.

func (*Config) Compare

func (c *Config) Compare(left *URLInfo, right *URLInfo) error

Compare compares left with right URL object and returs textual error when objects are different.

func (*Config) GetURLInfo

func (c *Config) GetURLInfo(url string) (*URLInfo, error)

GetURLInfo processes supplied URL.

type HTTPStatusChangedError

type HTTPStatusChangedError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	URL     string `json:"URL"`

	LeftStatusCode  int `json:"leftStatusCode"`
	RightStatusCode int `json:"rightStatusCode"`
}

HTTPStatusChangedError is returned when Compare method received URL infos with different status code.

func (*HTTPStatusChangedError) Error

func (e *HTTPStatusChangedError) Error() string

Error returs simple string representation of the error.

type NotEqualURLsError

type NotEqualURLsError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	URL     string `json:"URL"`

	ComparedURL string `json:"comparedURL"`
}

NotEqualURLsError is returned when Compare method received different URLs.

func (*NotEqualURLsError) Error

func (e *NotEqualURLsError) Error() string

Error returs simple string representation of the error.

type ThresholdTriggeredError

type ThresholdTriggeredError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	URL     string `json:"URL"`

	Current   int `json:"current"`
	Threshold int `json:"threshold"`
}

ThresholdTriggeredError is returned when URL infos triggered one of predefined thresholds during comparison.

func (*ThresholdTriggeredError) Error

func (e *ThresholdTriggeredError) Error() string

Error returs simple string representation of the error.

type URLInfo

type URLInfo struct {
	URL string `json:"URL"`

	StatusCode int `json:"statusCode"`
	BodyLength int `json:"bodyLength"`

	FuzzyHash []byte `json:"fuzzyHash"`

	Image     []byte `json:"image"`
	ImageHash []byte `json:"imageHash"`
}

URLInfo describes URL status for state comparison.

Jump to

Keyboard shortcuts

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