Documentation
¶
Overview ¶
patterns
patterns
patterns
patterns
patterns
Index ¶
- func ByteToKind(t reflect.Kind, data []byte) (interface{}, error)
- func Render(w io.Writer, n *html.Node) error
- type CompiledField
- type CompiledMap
- type CompiledRegexRules
- type CompiledXpathRules
- type Field
- type Map
- type PatternNode
- type Patterns
- func (p *Patterns) Apply(url string, content io.Reader) (map[string]interface{}, error)
- func (p *Patterns) Load(el *PatternNode, path string) error
- func (p *Patterns) LoadTree(path string) error
- func (p *Patterns) LoadXml(el *PatternNode, data []byte, itemName string) error
- func (p *Patterns) LoadYaml(el *PatternNode, data []byte, itemName string) error
- type RegexRules
- type Type
- type XpathRules
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CompiledField ¶
type CompiledField struct {
// contains filtered or unexported fields
}
func (*CompiledField) RelativePath ¶
func (f *CompiledField) RelativePath() string
get relative path like: "Root.SubField1.Subfield2..."
func (*CompiledField) Retrieve ¶
func (f *CompiledField) Retrieve(root *html.Node) (result interface{})
type CompiledMap ¶
type CompiledMap struct {
// contains filtered or unexported fields
}
type CompiledRegexRules ¶
type CompiledRegexRules struct {
Submatch *regexp.Regexp
Include []*regexp.Regexp
Exclude []*regexp.Regexp
Remove []*regexp.Regexp
}
func (*CompiledRegexRules) Clean ¶
func (p *CompiledRegexRules) Clean(s []byte) []byte
func (*CompiledRegexRules) FindMultiple ¶
func (p *CompiledRegexRules) FindMultiple(s []byte) [][]byte
func (*CompiledRegexRules) FindOne ¶
func (p *CompiledRegexRules) FindOne(s []byte) []byte
func (*CompiledRegexRules) Test ¶
func (p *CompiledRegexRules) Test(s []byte) bool
type CompiledXpathRules ¶
func (*CompiledXpathRules) Test ¶
func (p *CompiledXpathRules) Test(s xpath.NodeNavigator) bool
test if complies to defined rules
type Field ¶
type Field struct {
// field title
Title string `xml:"title,attr"`
// field type: int, string, float64, struct, html
Type string `xml:"type,attr"`
// xpath expression to find field
Path string
// data filter or transformaion based on regex expressions; see rules.go
Data *RegexRules
// data filter based on xpath expressions
XData *XpathRules
// optional field
Optional bool `xml:"optional,attr,omitempty"`
// deprecated
DontStore bool `xml:"dontstore,attr,omitempty"`
//
Multiple bool `xml:"multiple,attr,omitempty"`
// only unique fields
Unique bool `xml:"unique,attr,omitempty"`
// preserve HTML attributes (only works if field type="html")
Attr bool `xml:"attr,attr,omitempty"`
// sub-fields declaration
Field []*Field
}
Field struct declaration: <Field>...</Field>
func (*Field) Compile ¶
func (f *Field) Compile() (*CompiledField, error)
func (*Field) FindChildField ¶
type Map ¶
type Map struct {
// Title string `xml:"title,attr"`
Storage string `xml:"storage,attr,omitempty"`
Field *Field
URL *RegexRules
Mime string `xml:"mime,attr"`
}
func (*Map) Compile ¶
func (p *Map) Compile() (*CompiledMap, error)
func (*Map) MarshalXml ¶
func (*Map) MarshalYaml ¶
func (*Map) UnmarshalXml ¶
func (*Map) UnmarshalYaml ¶
type PatternNode ¶
type PatternNode map[string]interface{}
func (*PatternNode) ApplyPatterns ¶
func (pn *PatternNode) ApplyPatterns(url string, data *html.Node) map[string]interface{}
Applies XML patterns to input (URL "address" and HTML "content"). Returns map with result data.
func (*PatternNode) ListPatterns ¶
func (pn *PatternNode) ListPatterns() []string
type Patterns ¶
type Patterns struct {
Tree *PatternNode
Log *log.Logger
}
func NewPatterns ¶
type RegexRules ¶
func (*RegexRules) Compile ¶
func (p *RegexRules) Compile() (*CompiledRegexRules, error)
type XpathRules ¶
func (*XpathRules) Compile ¶
func (p *XpathRules) Compile() (*CompiledXpathRules, error)
brings to html cdata to compiled form
Click to show internal directories.
Click to hide internal directories.