parser

package
v0.0.0-...-c4769b5 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(format string, v ...interface{}) error

Errorf 抛出错误

Types

type HTMLDom

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

HTMLDom HTML Selector 解析器,类似jQuery的选择器, document.querySelector

func NewHTMLDom

func NewHTMLDom(body []byte) (*HTMLDom, error)

NewHTMLDom 创建一个HTML Selector 解析器

func (*HTMLDom) DomFind

func (t *HTMLDom) DomFind(selector string) *goquery.Selection

DomFind use document find a selector return html you can use chrome to select the dom selector, then .Html() fetch the special dom html

func (*HTMLDom) GetNodeText

func (t *HTMLDom) GetNodeText(node *html.Node) string

GetNodeText Get the specified node's text content.

func (*HTMLDom) Match

func (t *HTMLDom) Match(rule string) string

Match 配置规则,返回匹配到的值

func (*HTMLDom) MatchAll

func (t *HTMLDom) MatchAll(rule string) []string

MatchAll 配置规则,返回匹配到的值,复数

func (*HTMLDom) NodeAttr

func (t *HTMLDom) NodeAttr(node *html.Node, attr string) string

NodeAttr return node attr value

func (*HTMLDom) NodeHTML

func (t *HTMLDom) NodeHTML(node *html.Node) string

NodeHTML return node html

func (*HTMLDom) NodeText

func (t *HTMLDom) NodeText(node *html.Node) string

NodeText return node text

type JSONPath

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

JSONPath JSON Path解析器

func NewJSONPath

func NewJSONPath(body []byte) (*JSONPath, error)

NewJSONPath 创建一个JSON Path解析器

func (*JSONPath) Marshal

func (t *JSONPath) Marshal(v interface{}) []byte

Marshal 编码JSON

func (*JSONPath) Match

func (t *JSONPath) Match(rule string) interface{}

Match 配置规则,返回匹配到的值

func (*JSONPath) MatchAll

func (t *JSONPath) MatchAll(rule string) []interface{}

MatchAll 配置规则,返回匹配到的值,复数

type Parser

type Parser interface {
	// Match 配置规则,返回匹配到的值
	Match(rule string) string
	// Match 配置规则,返回匹配到的值,复数
	MatchAll(rule string) []string
}

Parser 字段分析接口

type Regexp

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

Regexp 正则解析器

func NewRegexp

func NewRegexp(body []byte) (*Regexp, error)

NewRegexp 创建一个正则匹配解析器

func (*Regexp) Match

func (t *Regexp) Match(rule string) string

Match 配置规则,返回匹配到的值

func (*Regexp) MatchAll

func (t *Regexp) MatchAll(rule string) []string

MatchAll 配置规则,返回匹配到的值,复数 RegexpMatchAll use regexp to match contents, but not real regexp, just support this: <li>(*)</li>

func (*Regexp) Regexp

func (t *Regexp) Regexp(pattern string) []string

Regexp use regexp to match contents, it is a real regexp rule

type Substring

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

Substring 字符串匹配

func NewSubstring

func NewSubstring(body []byte) (*Substring, error)

NewSubstring 创建一个字符串匹配解析器

func (*Substring) Match

func (t *Substring) Match(rule string) string

Match 配置规则,返回匹配到的值

func (*Substring) MatchAll

func (t *Substring) MatchAll(rule string) []string

MatchAll 配置规则,返回匹配到的值,复数

func (*Substring) RegexpMatchAll

func (t *Substring) RegexpMatchAll(pattern string) []string

RegexpMatchAll use regexp to match contents, but not real regexp, just support this: <li>(*)</li>

func (*Substring) StrMatch

func (t *Substring) StrMatch(start, end string) string

StrMatch use begin and end code to match content

func (*Substring) StrMatchAll

func (t *Substring) StrMatchAll(start, end string) []string

StrMatchAll use begin and end code to match all contents

Jump to

Keyboard shortcuts

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