fetchers

package
v0.0.0-...-cdee56d Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimpleLinkExtractor

func SimpleLinkExtractor(baseURL, currentURL string, body io.Reader) []string

SimpleLinkExtractor satisfies LinksExtractor. It reads the body and extracts the valid links

Types

type Client

type Client interface {
	Get(string) (*http.Response, error)
}

Client represents an object capable of performing a GET request

type Fetcher

type Fetcher interface {
	// Fetch returns the slice of URLs found on that page.
	// LinksExtractor allows processing links post fetching.
	Fetch(string, LinksExtractor) ([]string, error)
}

Fetcher represents an object capable of fetching URLs from a given url

type LinksExtractor

type LinksExtractor func(baseURL string, currentURL string, response io.Reader) []string

LinksExtractor extracts links from a given io.Reader It allows user to customize how the links should be extracted from given page.

type SimpleFetcher

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

SimpleFetcher implements Fetcher

func NewSimpleFetcher

func NewSimpleFetcher(url string) *SimpleFetcher

NewSimpleFetcher creates a new fetcher with the given base URL. It also creates a new http.Client with 5 seconds timeout

func (SimpleFetcher) Fetch

func (f SimpleFetcher) Fetch(url string, le LinksExtractor) ([]string, error)

Fetch pulls all the URLs on the page at `url`. Returns list of URLs found on the page

Jump to

Keyboard shortcuts

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