Documentation ¶
Index ¶
- Constants
- Variables
- func AllFilter() map[string]*Filter
- func RegisterFilter(name string, fn FilterFunction, description, usage, example string)
- func ReplaceFilter(name string, fn FilterFunction, description, usage, example string)
- func SplitParams(params string, separators ...string) []string
- func VerifySelector(selector string) (err error)
- type Fether
- type Filter
- type FilterFunction
- type PipeItem
- func (p *PipeItem) CallFilter(src interface{}, filters string) (interface{}, error)
- func (p *PipeItem) CopyFrom(from *PipeItem)
- func (p *PipeItem) Fetcher() Fether
- func (p *PipeItem) PipeBytes(body []byte, pageType string) (interface{}, error)
- func (p *PipeItem) SetFetcher(fetcher Fether)
- func (p *PipeItem) SetStorer(storer Storer)
- func (p *PipeItem) Storer() Storer
- type Storer
Constants ¶
View Source
const ( // begin new version PT_RAW = "raw" PT_INT = "int" PT_FLOAT = "float" PT_BOOL = "bool" PT_STRING = "string" PT_INT_ARRAY = "int-array" PT_FLOAT_ARRAY = "float-array" PT_BOOL_ARRAY = "bool-array" PT_STRING_ARRAY = "string-array" PT_HTML_ARRAY = "html-array" PT_MAP = "map" PT_ARRAY = "array" PT_JSON_VALUE = "json" PT_JSON_PARSE = "jsonparse" // begin compatible old version PT_TEXT = "text" PT_HREF = "href" PT_HTML = "html" PT_ATTR = `attr\[([\w\W]+)\]` PT_ATTR_ARRAY = `attr-array\[([\w\W]+)\]` PT_IMG_SRC = "src" PT_IMG_ALT = "alt" PT_TEXT_ARRAY = "text-array" PT_HREF_ARRAY = "href-array" PT_OUT_HTML = "outhtml" PAGE_JSON = "json" PAGE_HTML = "html" PAGE_JS = "js" PAGE_XML = "xml" PAGE_TEXT = "text" REGEXP_PRE = "regexp:" REGEXP2_PRE = "regexp2:" )
Variables ¶
View Source
var ( ErrJsonparseNeedSubItem = errors.New("Pipe type jsonparse need one subItem") ErrArrayNeedSubItem = errors.New("Pipe type array need one subItem") ErrNotSupportPipeType = errors.New("Not support pipe type") ErrUnknowHTMLAttr = errors.New("Unknow html attr") ErrUnsupportText2boolType = errors.New("Unsupport text2bool type") ErrUnsupportText2floatType = errors.New("Unsupport text2float type") ErrUnsupportText2intType = errors.New("Unsupport text2int type") ErrTrimNilParams = errors.New("Filter trim nil params") ErrSplitNilParams = errors.New("Filter split nil params") ErrJoinNilParams = errors.New("Filter join nil params") ErrFetcherNotRegistered = errors.New("Fetcher not registered") ErrStorerNotRegistered = errors.New("Storer not registered") ErrInvalidContent = errors.New("Invalid content") )
Functions ¶
func RegisterFilter ¶
func RegisterFilter(name string, fn FilterFunction, description, usage, example string)
func ReplaceFilter ¶
func ReplaceFilter(name string, fn FilterFunction, description, usage, example string)
func SplitParams ¶
Types ¶
type Filter ¶
type FilterFunction ¶
type PipeItem ¶
type PipeItem struct { Name string `json:"name,omitempty"` //只有类型为map的时候才会用到 Selector string `json:"selector,omitempty"` Type string `json:"type"` Filter string `json:"filter,omitempty"` SubItem []PipeItem `json:"subitem,omitempty"` // contains filtered or unexported fields }
func (*PipeItem) CallFilter ¶ added in v1.0.1
func (*PipeItem) SetFetcher ¶ added in v1.0.1
Click to show internal directories.
Click to hide internal directories.