wikipedia

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Page

type Page struct {
	ID       int
	Title    string
	Content  string
	Language string
	URL      string
	Redirect *redirect
}

Page contains the parsed data.

type Request

type Request struct {
	*url.URL
}

Request sets up the request against the api with the correct parameters and has functionality to fetch the data and convert it to a response.

func NewRequest

func NewRequest(baseURL, query, language string) (*Request, error)

NewRequest creates a new request against baseURL for language. Language is interpolated in the baseURL if asked, if not it is ignored. Query is the title of the page to fetch. Returns an error if the URL can not be parsed.

func (*Request) Execute

func (r *Request) Execute(ctx context.Context, noCheckCert bool) (*Response, error)

Execute fetches the data and decodes it into a Response. Returns an error if the data could not be retrieved or the decoding fails.

type Response

type Response struct {
	Batchcomplete string
	Query         query
}

Response contains the raw data the API returns.

func (*Response) Page

func (r *Response) Page() (*Page, error)

Page parses the raw data and returns a Page with the relevant data.

type Wikipedia

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

Wikipedia implements Source interface using wikipedia for lookups.

func New

func New(mwURL string) *Wikipedia

New initializes wikipedia based radium source implementation.

func (*Wikipedia) Search

func (wiki *Wikipedia) Search(ctx context.Context, query radium.Query) ([]radium.Article, error)

Search will query en.wikipedia.com to find results and extracts the first paragraph of the page.

Jump to

Keyboard shortcuts

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