scrapers

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const LayoutUnixTimestamp string = "unix"

date layout for unix timestamp: convert to time using time.Unix

Variables

View Source
var (
	ErrNoResultFound    = errors.New("no result found")
	ErrIsinMismatch     = errors.New("isin mismatch")
	ErrEmptyInfoURL     = errors.New("parse search returned an empty info URL")
	ErrInfoRequestIsNil = errors.New("info request is nil")
	ErrPriceNotFound    = errors.New("price not found")
	ErrDateNotFound     = errors.New("date not found")
)

Errors

Functions

func NewQuoteGetter

func NewQuoteGetter(scr Scraper) quotegetter.QuoteGetter

NewQuoteGetter trasforms a Scraper to a quotegetter.QuoteGetter interface

func SplitPriceCurrency

func SplitPriceCurrency(txt string, priceFirst bool) (priceStr string, currencyStr string, err error)

SplitPriceCurrency is ...

Types

type Error

type Error struct {
	*ParseInfoResult
	// contains filtered or unexported fields
}

Error is

func (*Error) Error

func (e *Error) Error() string

Error return the string representation of the error

func (*Error) Isin

func (e *Error) Isin() string

Isin returns the Isin of the error

func (*Error) Source

func (e *Error) Source() string

Source returns the Source of the error

func (*Error) URL

func (e *Error) URL() string

URL returns the URL of the error

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the inner error

type ErrorType

type ErrorType int

ErrorType is ...

const (
	Success ErrorType = iota
	NoResultFoundError
	IsinMismatchError
	GetSearchError
	ParseSearchError
	GetInfoError
	ParseInfoError
	PriceNotFoundError
	InvalidPriceError
	DateNotFoundError
	InvalidDateError
	IsinNotFoundError
)

ErrorType enum

func (ErrorType) String

func (i ErrorType) String() string

type ParseInfoResult

type ParseInfoResult struct {
	IsinStr     string
	PriceStr    string
	CurrencyStr string
	DateStr     string
	DateLayout  string
}

ParseInfoResult is ...

type Scraper

type Scraper interface {
	Source() string
	Client() *http.Client
	GetSearch(ctx context.Context, isin string) (*http.Request, error)
	ParseSearch(doc *goquery.Document, isin string) (string, error)
	GetInfo(ctx context.Context, isin, url string) (*http.Request, error)
	ParseInfo(doc *goquery.Document, isin string) (*ParseInfoResult, error)
}

Scraper interface. An object implementing the Scraper interface can be used to satisfy the QuoteGetter interface also.

The GetQuote function of the QuoteGetter is made up by the GetSearch, ParseSearch, GetInfo and ParseInfo function.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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