site

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonFetchMultiTorrents

func CommonFetchMultiTorrents(ctx context.Context, c *colly.Collector, conf *SiteMapConfig, urls []string) ([]*models.PHPTorrentInfo, error)

CommonFetchMultiTorrents 并发抓取多个种子信息 CommonFetchMultiTorrents 并发抓取多个种子信息,并返回结果和单一错误

func CommonFetchTorrentInfo

func CommonFetchTorrentInfo(ctx context.Context, c *colly.Collector, conf *SiteMapConfig, url string) (*models.PHPTorrentInfo, error)

CommonFetchTorrentInfo 获取种子信息

func GetSeedCache added in v0.0.12

func GetSeedCache(ctx context.Context) *bigcache.BigCache

func NewCollectorWithTransport

func NewCollectorWithTransport() *colly.Collector

Types

type CMCTParser added in v0.0.3

type CMCTParser struct {
	Config ParserConfig
}

CMCTParser 实现了 SiteParser 接口

func NewCMCTParser added in v0.0.3

func NewCMCTParser(options ...ParserOption) *CMCTParser

func (*CMCTParser) ParseDiscount added in v0.0.3

func (p *CMCTParser) ParseDiscount(e *colly.HTMLElement, info *models.PHPTorrentInfo)

ParseDiscount 解析优惠类型和结束时间

func (*CMCTParser) ParseHR added in v0.0.3

func (p *CMCTParser) ParseHR(e *colly.HTMLElement, info *models.PHPTorrentInfo)

ParseHR 解析 HR 状态

func (*CMCTParser) ParseTitleAndID added in v0.0.3

func (p *CMCTParser) ParseTitleAndID(e *colly.HTMLElement, info *models.PHPTorrentInfo)

ParseTitleAndID 解析标题和种子 ID

func (*CMCTParser) ParseTorrentSizeMB added in v0.0.3

func (p *CMCTParser) ParseTorrentSizeMB(e *colly.HTMLElement, info *models.PHPTorrentInfo)

type DefaultReferer

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

func NewDefaultReferer

func NewDefaultReferer(siteName models.SiteGroup) *DefaultReferer

NewDefaultReferer 构造函数,用于初始化 refererMap

func (*DefaultReferer) GetReferer

func (d *DefaultReferer) GetReferer() string

GetReferer 实现 RefererProvider 接口

type HDSkyParser

type HDSkyParser struct {
	Config ParserConfig
}

HDSkyParser 实现了 SiteParser 接口

func NewHDSkyParser

func NewHDSkyParser(options ...ParserOption) *HDSkyParser

func (*HDSkyParser) ParseDiscount

func (p *HDSkyParser) ParseDiscount(e *colly.HTMLElement, info *models.PHPTorrentInfo)

ParseDiscount 解析优惠类型和结束时间

func (*HDSkyParser) ParseHR

func (p *HDSkyParser) ParseHR(e *colly.HTMLElement, info *models.PHPTorrentInfo)

ParseHR 解析 HR 状态

func (*HDSkyParser) ParseTitleAndID

func (p *HDSkyParser) ParseTitleAndID(e *colly.HTMLElement, info *models.PHPTorrentInfo)

ParseTitleAndID 解析标题和种子 ID

func (*HDSkyParser) ParseTorrentSizeMB

func (p *HDSkyParser) ParseTorrentSizeMB(e *colly.HTMLElement, info *models.PHPTorrentInfo)

type ParserConfig

type ParserConfig struct {
	TimeLayout string // 时间格式
}

ParserConfig 定义解析器的配置

type ParserOption

type ParserOption func(*ParserConfig)

func WithTimeLayout

func WithTimeLayout(layout string) ParserOption

type RefererProvider

type RefererProvider interface {
	GetReferer() string
}

type SharedSiteConfig

type SharedSiteConfig struct {
	Cookie  string            // 登录 Cookie
	Headers map[string]string // 通用 HTTP 请求头
	SiteCfg SiteConfig        // 动态配置,包括 Referer
}

type SiteConfig

type SiteConfig struct {
	RefererConf RefererProvider
}

type SiteMapConfig

type SiteMapConfig struct {
	Name          string            // 站点名称
	SharedConfig  *SharedSiteConfig // 共享配置
	Config        models.SiteConfig
	Parser        SiteParser        // 站点特定解析器
	CustomHeaders map[string]string // 特定站点覆盖的请求头
}

func NewSiteMapConfig

func NewSiteMapConfig(name models.SiteGroup, cookie string, conf models.SiteConfig, parser SiteParser) *SiteMapConfig

单个 URL 创建单个 SiteMapConfig

type SiteParser

type SiteParser interface {
	ParseTitleAndID(e *colly.HTMLElement, info *models.PHPTorrentInfo)
	ParseDiscount(e *colly.HTMLElement, info *models.PHPTorrentInfo)
	ParseHR(e *colly.HTMLElement, info *models.PHPTorrentInfo)
	ParseTorrentSizeMB(e *colly.HTMLElement, info *models.PHPTorrentInfo)
}

Jump to

Keyboard shortcuts

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