mech

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mech provides some simple automation for working with web sites

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(url, dst string, perms ...uint32) (filepath string, err error)

Download wrapper for instance method

func GetLinks(url string) (links []string, err error)

GetLinks wrapper for instance method

func Stream

func Stream(url string) (reader io.ReadCloser, err error)

Stream wrapper for instance method

Types

type Mech

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

Mech provides some simple automation for working with web sites

func New

func New() (mech *Mech)

New creates a new Mech instance

func (*Mech) Download

func (mech *Mech) Download(url, dst string, perms ...uint32) (filepath string, err error)

Download from the given URL to the given destination returning the full path to the resulting downloaded file

func (*Mech) Get

func (mech *Mech) Get(url string) (page *Page, err error)

Get the target html docuement as a *Page Caller is responsible for Closing the Page

func (mech *Mech) GetLinks(url string) (links []string, err error)

GetLinks from the target html docuement

func (*Mech) Stream

func (mech *Mech) Stream(url string) (reader io.ReadCloser, err error)

Stream the given url Caller is responsible for closing the reader when finished

type Page

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

Page encapsulates an HTML document and provides helper methods

func Get

func Get(url string) (page *Page, err error)

Get wrapper for instance method

func (*Page) Close

func (page *Page) Close() error

Close implementes the Closer interface

func (*Page) Find

func (page *Page) Find(selector string) (goquery *goquery.Selection, err error)

Find exposes the underlying goquery Find function

func (page *Page) Links() (links []string, err error)

Links returns all links for the given page

func (*Page) Parse

func (page *Page) Parse() (err error)

Parse the page as a goquery document if not already done. This method is idempotent and will only parse the document if not already done so.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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