filter

package
v0.0.0-...-36a46f5 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(r io.Reader, filters ...FilterFn) ([]*html.Node, error)

Filter receives an io.Reader from which to extract the HTML nodes.

It returns an error if there is any problem while extracting the tokens to create the HTML nodes.

You can pass none, one or more FilterFn functions to apply. The order of the filters affects the result.

It finally returns an []*html.Node.

func Images

func Images(r io.Reader) ([]string, error)

Images receives an io.Reader from which to extract all the image sources. It returns an error if there is any problem while extrating the tokens to create the HTML nodes from which extract the images sources. If nothing goes wrong it returns a []string with all the image sources found.

func Links(r io.Reader) ([]string, error)

Links receives an io.Reader from which to extract all the links. It returns an error if there is any problem while extrating the tokens to create the HTML nodes from which extract the links. If nothing goes wrong it returns a []string with all the links found.

Types

type FilterFn

type FilterFn func(n *html.Node) bool

FilterFn defines a filter to filter HTML nodes. If the filter returns true, the HTML node is added to the result of the Filter function. If the filter returns false the HTML node is excluded.

func FilterByAttr

func FilterByAttr(attr string) FilterFn

FilterByAttr receives an HTML attribute and returns a FilterFn that can be used as a filter on the Filter function.

func FilterByClass

func FilterByClass(class string) FilterFn

FilterByClass receives a CSS class and returns a FilterFn that can be used as a filter on the Filter function.

func FilterByID

func FilterByID(id string) FilterFn

FilterByID receives an ID and returns a FilterFn that can be used as a filter on the Filter function.

func FilterByTag

func FilterByTag(tag string) FilterFn

FilterByTag receives an HTML tag without "<" nor ">" and returns a FilterFn that can be used as a filter on the Filter function.

Jump to

Keyboard shortcuts

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