Documentation ¶
Index ¶
- Variables
- func Cookie(n string, v string)
- func Get(url string) (string, error)
- func GetWithClient(url string, client *http.Client) (string, error)
- func Header(n string, v string)
- func Post(url string, bodyType string, body interface{}) (string, error)
- func PostForm(url string, data url.Values) (string, error)
- func PostWithClient(url string, bodyType string, body interface{}, client *http.Client) (string, error)
- func SetDebug(d bool)
- type Error
- type ErrorType
- type Root
- func (r Root) Attrs() map[string]string
- func (r Root) Children() []Root
- func (r Root) Find(args ...string) Root
- func (r Root) FindAll(args ...string) []Root
- func (r Root) FindAllStrict(args ...string) []Root
- func (r Root) FindNextElementSibling() Root
- func (r Root) FindNextSibling() Root
- func (r Root) FindPrevElementSibling() Root
- func (r Root) FindPrevSibling() Root
- func (r Root) FindStrict(args ...string) Root
- func (r Root) FullText() string
- func (r Root) HTML() string
- func (r Root) Text() string
Constants ¶
This section is empty.
Variables ¶
var ( // Headers contains all HTTP headers to send Headers = make(map[string]string) // Cookies contains all HTTP cookies to send Cookies = make(map[string]string) )
Init a new HTTP client for use when the client doesn't want to use their own.
Functions ¶
func GetWithClient ¶
GetWithClient returns the HTML returned by the url using a provided HTTP client
Types ¶
type Error ¶
type Error struct { Type ErrorType // contains filtered or unexported fields }
Error allows easier introspection on the type of error returned. If you know you have a Error, you can compare the Type to one of the exported types from this package to see what kind of error it is, then further inspect the Error() method to see if it has more specific details for you, like in the case of a ErrElementNotFound type of error.
type ErrorType ¶
type ErrorType int
ErrorType defines types of errors that are possible from soup
const ( // ErrUnableToParse will be returned when the HTML could not be parsed ErrUnableToParse ErrorType = iota // ErrElementNotFound will be returned when element was not found ErrElementNotFound // ErrNoNextSibling will be returned when no next sibling can be found ErrNoNextSibling // ErrNoPreviousSibling will be returned when no previous sibling can be found ErrNoPreviousSibling // ErrNoNextElementSibling will be returned when no next element sibling can be found ErrNoNextElementSibling // ErrNoPreviousElementSibling will be returned when no previous element sibling can be found ErrNoPreviousElementSibling // ErrCreatingGetRequest will be returned when the get request couldn't be created ErrCreatingGetRequest // ErrInGetRequest will be returned when there was an error during the get request ErrInGetRequest // ErrCreatingPostRequest will be returned when the post request couldn't be created ErrCreatingPostRequest // ErrMarshallingPostRequest will be returned when the body of a post request couldn't be serialized ErrMarshallingPostRequest // ErrReadingResponse will be returned if there was an error reading the response to our get request ErrReadingResponse )
type Root ¶
Root is a structure containing a pointer to an html node, the node value, and an error variable to return an error if one occurred
func (Root) Find ¶
Find finds the first occurrence of the given tag name, with or without attribute key and value specified, and returns a struct with a pointer to it
func (Root) FindAll ¶
FindAll finds all occurrences of the given tag name, with or without key and value specified, and returns an array of structs, each having the respective pointers
func (Root) FindAllStrict ¶
FindAllStrict finds all occurrences of the given tag name only if all the values of the provided attribute are an exact match
func (Root) FindNextElementSibling ¶
FindNextElementSibling finds the next element sibling of the pointer in the DOM returning a struct with a pointer to it
func (Root) FindNextSibling ¶
FindNextSibling finds the next sibling of the pointer in the DOM returning a struct with a pointer to it
func (Root) FindPrevElementSibling ¶
FindPrevElementSibling finds the previous element sibling of the pointer in the DOM returning a struct with a pointer to it
func (Root) FindPrevSibling ¶
FindPrevSibling finds the previous sibling of the pointer in the DOM returning a struct with a pointer to it
func (Root) FindStrict ¶
FindStrict finds the first occurrence of the given tag name only if all the values of the provided attribute are an exact match