utils

package
v3.0.12 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

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

常用的User-Agent

Variables

This section is empty.

Functions

func Base64ToImage

func Base64ToImage(base64Str string) (image.Image, error)

base64转图片

func CalculateJPEGMD5

func CalculateJPEGMD5(img image.Image, quality int) (string, error)

使用 JPEG 编码图像后计算其 MD5

func ConvertToGray

func ConvertToGray(img image.Image) *image.Gray

ConvertToGray 将彩色图像转换为灰度图

func CookiesAddNoRepetition

func CookiesAddNoRepetition(addTarget *[]*http.Cookie, oldTarget []*http.Cookie)

添加Cookies,并且是无重复添加,意思就是添加到目标Cookies里面时会检测是否有重复Key的Cookie,如果有则直接替换Cookie值

func CookiesFiltration

func CookiesFiltration(keys []string, cookies []*http.Cookie) []*http.Cookie

过滤并获取指定Cookies并返回

func CqieEncrypt

func CqieEncrypt(str string) []byte

加密函数:如果输入的 o 有效,则使用 SM4 加密

func DeleteFile

func DeleteFile(path string)

func ExtractAssets

func ExtractAssets(dir string, names ...string) error

ExtractAssets writes the named embedded legacy assets to dir.

Library callers can use this to materialize only the helper binaries a platform needs instead of calling YatoriCoreInit, which extracts the complete legacy asset bundle into the process working directory.

func GetFaceBase64

func GetFaceBase64() (image.Image, error)

过人脸数据

func GetImageShape

func GetImageShape(img image.Image) (height, width, channels int)

func HumanDelay

func HumanDelay(min, max time.Duration)

HumanDelay 拟人化随机等待 [min, max](含两端)。 用于在连续接口调用之间插入不固定的间隔,避免固定/过快的请求节奏被识别为非人类特征。

func ImageRGBDisturb

func ImageRGBDisturb(img image.Image) image.Image

像素干扰

func ImageRGBDisturbAdjust

func ImageRGBDisturbAdjust(img image.Image, strength int) image.Image

ImageRGBDisturb 对图像像素颜色进行随机扰动,强度范围 [0,255]

func ImageToGrayFloatArray

func ImageToGrayFloatArray(img image.Image) []float32

图片转一维数组数据 ImageToGrayFloatArray 将灰度图像转换为一维浮点数组,范围为 [0.0, 1.0]

func IsBadImg

func IsBadImg(imgFile string) bool

检测图片是否损坏,损坏为true,没损坏为false

func LoadImage

func LoadImage(filePath string) (image.Image, error)

LoadImage 读取指定路径的图片并返回 image.Image 对象。 支持 JPEG 和 PNG 格式的图片。

func ParseWorkInform

func ParseWorkInform(doc *goquery.Document) (map[string]interface{}, error)

用于截取作业信息中用于回答回答题目的关键参数

func PathExistForCreate

func PathExistForCreate(path string)

检测目录是否存在,不存在就创建

func PathExists

func PathExists(path string) (bool, error)

检测文件夹或文件是否存在

func ProcessImageDisturb

func ProcessImageDisturb(img image.Image) image.Image

ProcessImageDisturb 对输入图像进行轻度像素扰动并返回新的 image.Image

func ReadFileAsString

func ReadFileAsString(path string) (string, error)

ReadFileAsString 读取文本文件并以 string 返回

func ReadImg

func ReadImg(imgFile string) (image.Image, error)

从文件读取imgage

func ResizeImage

func ResizeImage(img image.Image, width, height uint) *image.RGBA

ResizeImage 将图片缩放到指定宽度和高度并返回 RGB 图像

func RunFuncName

func RunFuncName() string

RunFuncName 获取正在运行的函数名

func SaveImageAsJPEG

func SaveImageAsJPEG(img image.Image, path string) error

saveImageAsJPEG 将图像保存为 JPEG 到指定路径

func SaveTextToFile

func SaveTextToFile(path, content string, appendMode bool, fileMode os.FileMode) error

SaveTextToFile 将 content 写入到 path 指定的文件。 如果 appendMode 为 true,则以追加模式写入(文件不存在会创建); 否则以覆盖模式写入(会创建或截断已有文件)。 fileMode 指定创建文件时的权限(如 0644)。

func TokenHex

func TokenHex(len int) string

用于生成IMEI

func TurnCookiesFromString

func TurnCookiesFromString(cookieStr string) []*http.Cookie

TurnCookiesFromString 将一整串 cookie 字符串解析成*http.Cookie数组并返回

func YatoriCoreInit

func YatoriCoreInit()

Types

type QuestionSet

type QuestionSet struct {
	ID   string // 可以根据需要添加其他字段,例如题目ID
	HTML string
}

QuestionSet 结构体用于存储每个 div.Py-mian1 的原始 HTML 内容

func ParseQuestionSets

func ParseQuestionSets(doc *goquery.Document) []QuestionSet

ParseQuestionSets 函数用于提取所有 div.Py-mian1 节点的原始 HTML 内容

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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