util

package
v0.0.0-...-e203b1b Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSupportedBackends

func GetSupportedBackends() []string

GetSupportedBackends returns a list of the names of all wiki backends supported by wikiscrape.

func GetSupportedWikis

func GetSupportedWikis() []string

GetSupportedWikis returns a list of the names of all wikis supported by wikiscrape

func GetWikiInfoFromHost

func GetWikiInfoFromHost(host string) (*wikiInfo, error)

GetWikiInfoFromHost takes a URL host segment and returns its corresponding wikiInfo. Fails if the wiki is not supported by wikiscrape.

func GetWikiInfoFromName

func GetWikiInfoFromName(name string) (*wikiInfo, error)

GetWikiInfoFromName takes a wiki name and returns its corresponding wikiInfo. Fails if the wiki is not supported by wikiscrape.

func GetWikiInfoStrings

func GetWikiInfoStrings(backendFilter string) []string

GetWikiInfoStrings returns a formatted slice of strings containing relevant information about the wikis supported by wikiscrape. This function is designed for use with the List command.

func TrimLower

func TrimLower(s string) string

Types

type Manifest

type Manifest []string

func ReadManifestFrom

func ReadManifestFrom(filepath string) (Manifest, error)

ReadManifestFrom accepts a path to a JSON file containing an array of page names and reads its content.

type QueryData

type QueryData struct {
	Info *wikiInfo
	Page string
}

QueryData represents all the information the internal/wiki and internal/scraper packages need to make queries to their respective APIs.

func GetQueryDataFromName

func GetQueryDataFromName(pageName string, wikiName string) (*QueryData, error)

GetQueryDataFromName accepts a page name and wikiname, checks for explicit support (existing wikiInfo entry in the wikiNameInfo map) and returns a QueryData object which provides all the necessary information to make a query to the wiki's api.

func GetQueryDataFromURL

func GetQueryDataFromURL(rawURL string) (*QueryData, error)

GetQueryDataFromURL accepts a raw wiki url, parses it's host name, checks for explicit support (existing wikiInfo entry in the wikiHostInfo map) and returns a QueryData object which provides all the necessary information to make a query to the wiki's api.

type WikiNotSupportedError

type WikiNotSupportedError struct {
	Code string
	Info string
}

Custom error designed indicate to the user that the wiki they are trying to escape is not explicitly supported by the program.

func (*WikiNotSupportedError) Error

func (e *WikiNotSupportedError) Error() string

Error returns a formatted WikiNotSupportedError including code and additional information.

Jump to

Keyboard shortcuts

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