scraper

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewScrapeError

func NewScrapeError(scraper, message string, err error, context map[string]interface{}) error

Types

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

type GenericScraper added in v0.1.1

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

func NewGenericScraper added in v0.1.1

func NewGenericScraper(opts *ScraperOption) *GenericScraper

func (*GenericScraper) Scrape added in v0.1.1

func (generic *GenericScraper) Scrape(ctx context.Context, url string) <-chan ScrapeData

type ScrapeData

type ScrapeData struct {
	Index int
	URL   string
	Title string
	Data  []*html.Node
	Err   error
}

type ScrapeError

type ScrapeError struct {
	Err     error
	Message string
	Context map[string]interface{}
	Scraper string
}

func (ScrapeError) Display added in v0.1.1

func (scrape ScrapeError) Display() json.RawMessage

func (ScrapeError) Error

func (err ScrapeError) Error() string

func (*ScrapeError) MarshalJSON

func (scrapeerror *ScrapeError) MarshalJSON() ([]byte, error)

type Scraper

type Scraper interface {
	Scrape(ctx context.Context, url string) <-chan ScrapeData
}

type ScraperOption added in v0.1.1

type ScraperOption struct {
	Domain          string
	ContentSelector string
	TitleSelector   string
	NextSelector    string
	// 1 Based index digit.
	StartIndex int
	// 1 Based index digit.
	EndIndexReducer int
	Threads         int
	Client          Doer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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