Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultThread = 12 // 默认协程数量 CollyConfName = "__conf.name" // 配置名称 CollyConfStepName = "__conf.step.name" // 步骤名称 CollyConfExt = "__conf.ext" // 额外信息 CollyConfStepStart = "start" // 开始步骤名称 CollyConfStepEnd = "final" // 结束步骤名称 CollyPipelineURL = "_url" // 结果 - 请求的url )
Variables ¶
View Source
var (
ErrNotStorage = errors.New("not found configurable storage")
)
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
func (*Collector) PackageName ¶
type DirStorage ¶
type DirStorage struct {
// contains filtered or unexported fields
}
func NewDirStorage ¶
func NewDirStorage(path string, fs2 *embed.FS) (*DirStorage, error)
type FileConfig ¶
type FileConfig struct { Name string `json:"name"` BaseURL string `json:"url"` BaseHttpMethod string `json:"http_method"` Proxy string `json:"proxy"` Steps map[string][]Step `json:"steps"` Final map[string]Element `json:"final"` }
func (*FileConfig) GetBaseRequest ¶
func (f *FileConfig) GetBaseRequest(urls ...string) *colly.Request
func (*FileConfig) GetBaseURL ¶
func (f *FileConfig) GetBaseURL() string
func (*FileConfig) GetFinal ¶
func (f *FileConfig) GetFinal() map[string]Element
func (*FileConfig) GetName ¶
func (f *FileConfig) GetName() string
func (*FileConfig) GetProxy ¶
func (f *FileConfig) GetProxy() string
func (*FileConfig) GetStep ¶
func (f *FileConfig) GetStep(name string) []Step
type Option ¶
type Option func(c *Collector)
func WithCollector ¶
func WithCollector(collector *colly.Collector) Option
func WithConfigStorage ¶
func WithLogger ¶
func WithPipeline ¶
func WithPipeline(pipeLineFunc PipelineFunc) Option
type PipelineFunc ¶
type Step ¶
type Step struct { HttpMethod string `mapstructure:"http_method" json:"http_method"` // Http请求方式 默认:GET CSSPath string `mapstructure:"css_path" json:"css_path"` // CSSPath提取 Attr string `mapstructure:"attr" json:"attr"` // 节点内容提取 Next string `mapstructure:"next" json:"next"` // 下一步步骤 其中start-end 分别表示开始和抽取结果 Ext map[string]Element `mapstructure:"ext" json:"ext"` // 额外节点信息 }
func (Step) GetHttpMethod ¶
Click to show internal directories.
Click to hide internal directories.