Documentation ¶
Overview ¶
parsers is an interface that Colibri can use to parse the content of responses.
Index ¶
- Constants
- Variables
- func Set[T colibri.Node](parsers *Parsers, expr string, parserFunc func(colibri.Response) (T, error)) error
- type HTMLNode
- func (html *HTMLNode) CSSFind(expr string) (colibri.Node, error)
- func (html *HTMLNode) CSSFindAll(expr string) ([]colibri.Node, error)
- func (html *HTMLNode) Find(selector *colibri.Selector) (colibri.Node, error)
- func (html *HTMLNode) FindAll(selector *colibri.Selector) ([]colibri.Node, error)
- func (html *HTMLNode) Value() any
- func (html *HTMLNode) XPathFind(expr string) (colibri.Node, error)
- func (html *HTMLNode) XPathFindAll(expr string) ([]colibri.Node, error)
- type JSONode
- type Parsers
- type TextNode
- type XMLNode
Constants ¶
const ( XPathExpr = "xpath" CSSelector = "css" RegularExpr = "regular" )
const HTMLRegexp = `^text\/html`
HTMLRegexp contains a regular expression that matches the HTML MIME type.
const JSONRegexp = `^application\/(json|x-json|([a-z]+\+json))`
JSONRegexp contains a regular expression that matches the JSON MIME type.
const TextRegexp = `^text\/plain`
TextRegexp contains a regular expression that matches the MIME type plain text.
const XMLRegexp = `(?i)((application|image|message|model)/((\w|\.|-)+\+?)?|text/)(wb)?xml`
XMLRegexp contains a regular expression that matches the XML MIME type.
Variables ¶
var ( // ErrNotMatch is returned when Content-Tyepe does not match Paser. ErrNotMatch = errors.New("Content-Type does not match") // ErrExprType is returned when the expression type is not supported by the node. ErrExprType = errors.New("ExprType not compatible with node") )
Functions ¶
Types ¶
type HTMLNode ¶
type HTMLNode struct {
// contains filtered or unexported fields
}
type JSONode ¶
type JSONode struct {
// contains filtered or unexported fields
}
type Parsers ¶
type Parsers struct {
// contains filtered or unexported fields
}
Parsers is used to parse the content of the answers. When a regular expression matches the content type of the response, the content of the response is parsed with the parser corresponding to the regular expression.
func New ¶
New returns a new default parser to parse HTML, XHML, JSON, and plain text. See the colibri.Parser interface.
type TextNode ¶
type TextNode struct {
// contains filtered or unexported fields
}