Documentation
¶
Index ¶
- Variables
- func GenerateUUID() (string, error)
- func Max[T Element](x, y T) T
- func Min[T Element](x, y T) T
- func NewGoogleCapture()
- type BaiduCapture
- type BingCapture
- type BingFormat
- type BloomFilter
- type Cache
- type Capture
- type Downloader
- type Element
- type GoogleCapture
- type ImageReader
- type ImageSize
- type Option
- type Rule
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDownloadFailed = errors.New("failed to download image") // 下载失败 ErrMaxRetryExceeded = errors.New("maximum retry attempts exceeded") // 达到最大重试次数 // 网络连接或URL相关错误 ErrInvalidURL = errors.New("invalid URL") // URL格式不正确 ErrConnectionFailed = errors.New("connection failed") // 网络连接失败 ErrTimeout = errors.New("connection timeout") // 连接超时 ErrHostUnreachable = errors.New("host unreachable") // 无法访问主机 // 文件操作相关错误 ErrFileCreationFailed = errors.New("file creation failed") // 创建文件失败 ErrFileWriteFailed = errors.New("file write failed") // 文件写入失败 ErrFilePermissionDenied = errors.New("file permission denied") // 文件权限不足 ErrDiskSpaceInsufficient = errors.New("insufficient disk space") // 磁盘空间不足 // 数据读取与解码相关错误 ErrReadFailed = errors.New("failed to read data from source") // 数据读取失败 ErrDataDecodingFailed = errors.New("failed to decode data") // 数据解码失败 // 目标路径相关错误 ErrInvalidTargetPath = errors.New("invalid target path") // 目标路径不正确 ErrDirectoryNotWritable = errors.New("target directory not writable") // 目标目录无法写入 ErrFileAlreadyExists = errors.New("file already exists") // 文件已存在 // 下载内容相关错误 ErrUnsupportedFileType = errors.New("unsupported file type") // 文件类型不支持 ErrContentTooLarge = errors.New("content size exceeds limit") // 内容大小超过限制 ErrContentChecksumMismatch = errors.New("content checksum mismatch") // 校验和不匹配,可能数据损坏 )
* @Author: zouyx * @Email: 1003941268@qq.com * @Date: 2024/11/4 上午10:48 * @Package:
View Source
var ( // 抖音源 RULE_DOUYIN = Rule{ "douyin.com", "douyinpic.com", "ixigua.com", "snssdk.com", "amemv.com", "tiktok.com", } // 新浪源 RULES_SINA = Rule{ "sinaimg.cn", "sinajs.cn", "sina.com.cn", "vip.sina.com", } )
Functions ¶
func NewGoogleCapture ¶
func NewGoogleCapture()
Types ¶
type BaiduCapture ¶
type BaiduCapture struct { Downloader // contains filtered or unexported fields }
BaiduCapture 实现百度图片搜索引擎
func (*BaiduCapture) RangeImages ¶
func (*BaiduCapture) SearchImages ¶
type BingCapture ¶
type BingCapture struct { Downloader // contains filtered or unexported fields }
func (*BingCapture) RangeImages ¶
func (*BingCapture) SearchImages ¶
type BingFormat ¶
type BloomFilter ¶ added in v1.0.2
type BloomFilter struct {
// contains filtered or unexported fields
}
func NewBloomFilter ¶ added in v1.0.2
func NewBloomFilter(expectedItems uint, falsePositiveRate float64) *BloomFilter
func (*BloomFilter) Add ¶ added in v1.0.2
func (bf *BloomFilter) Add(item string)
func (*BloomFilter) Contains ¶ added in v1.0.2
func (bf *BloomFilter) Contains(item string) bool
type Capture ¶
type Capture interface { Downloader /** 搜索图片: 注 【对图片去重后返回的图片是无序的】 @param keywords: 搜索关键词 @param maxNumber: 最多返回的图片数量 @param opts: 额外参数,支持多种选项 @return: 返回图片 URL 列表和可能的错误 */ SearchImages(keyword string, maxNumber int, opts ...Option) ([]string, error) /** 分页范围图片搜索:用于分批获取搜索结果 @param keyword: 搜索关键词 @param callBack: 回调函数,用于处理返回的每一批次图片 URL 列表的函数。如果 `fn` 返回 `false`,则停止后续搜索 @param opts: 额外参数,支持多种选项 @return: 返回当前页码的图片 URL 列表和可能的错误 */ RangeImages(keyword string, callBack func(urls []string) bool, opts ...Option) error }
* @Author: zouyx * @Email:1003941268@qq.com * @Date: 2024/11/1 下午6:25 * @Package:
func NewBaiduCapture ¶
NewBaiduCapture 初始化百度图片搜索引擎 传入最大支持并发数量,建议不超过6个
func NewBingCapture ¶
type Downloader ¶
type Downloader interface { // 下载图片到指定文件路径。如果 writer 不为 nil,将数据写入 writer;否则保存到 filename 文件中。 // @param url: 图片 URL // @param filename: 保存的文件名 // @param writer: 可选的 io.Writer 用于写入数据 // @return: 下载成功返回文件名后缀 eg:[png],返回可能的错误 Download(url, filename string, writer io.Writer) (string, error) //// 批量下载所有图片到指定目录,是否以图片的 MD5 值命名,返回已下载成功的文件路径。 //// @param urls: 图片 URL 列表 //// @param dir: 保存目录 //// @param useMd5Naming: 是否使用 MD5 值命名 //// @return: 返回已成功下载的文件路径列表和可能的错误 BatchDownload(urls []string, dir string, useMd5Naming bool) ([]string, error) }
type GoogleCapture ¶
type GoogleCapture struct{}
func (GoogleCapture) BatchDownload ¶
func (GoogleCapture) Download ¶
func (GoogleCapture) Download(url, filename string, writer io.Writer) error
func (GoogleCapture) SearchImages ¶
type ImageReader ¶
func NewImageReader ¶
func NewImageReader(reader io.Reader, needMd5 bool) (*ImageReader, error)
func (ImageReader) Md5 ¶
func (ir ImageReader) Md5() string
func (ImageReader) Type ¶
func (ir ImageReader) Type() string
type ImageSize ¶
type ImageSize uint
需要搜索的图片大小
const ( ImageSize_SMALL ImageSize // 小图 ImageSize_MEDIUM // 中图 ImageSize_LARGE // 大图 ImageSize_ENORMOUS // 特大图片 )
Click to show internal directories.
Click to hide internal directories.