Documentation ¶
Index ¶
- func GeoSearch(latitude float32, longitude float32, radius float32, title string, limit int) ([]string, error)
- func GetAvailableLanguage() (map[string]string, error)
- func GetPage(title string, pageid int, suggest bool, redirect bool) (page.WikipediaPage, error)
- func GetRandom(limit int) ([]string, error)
- func Search(_input string, limit int, suggest bool) ([]string, string, error)
- func SetCacheDuration(x time.Duration)
- func SetLanguage(lang string)
- func SetMaxCacheMemory(n int)
- func SetURL(url string)
- func SetUserAgent(user string)
- func Suggest(_input string) (string, error)
- func Summary(title string, numsentence int, numchar int, suggest bool, redirect bool) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeoSearch ¶
func GeoSearch(latitude float32, longitude float32, radius float32, title string, limit int) ([]string, error)
Do a wikipedia geo search for `latitude` and `longitude` using HTTP API described in http://www.mediawiki.org/wiki/Extension:GeoData
Arguments:
* latitude: Latitude of the searched place
* longitude: longitude of the searched place
* title(optional): The title of an article to search for. Use "" to use the default setting
* limit(optional): The maximum number of results returned. Use -1 to use the default setting
* radius(optional): Search radius in meters. The value must be between 10 and 10000. Use -1 to use the default setting
Return:
* A slice of geosearch titles
* Error
func GetAvailableLanguage ¶
List all the currently supported language prefixes (usually ISO language code). Can be inputted to `set_lang` to change the Mediawiki that `wikipedia` requests results from.
Returns: Map of <prefix>: <local_lang_name> pairs.
func GetPage ¶
Get a WikipediaPage object for the page with title `title` or the pageid `pageid` (mutually exclusive).
Keyword arguments:
* title: The title of the page to load
* pageid: The numeric pageid of the page to load
* auto_suggest: Let Wikipedia find a valid page title for the query. Default should be False
* redirect: Allow redirection. Default should be True
Return:
* A WikipediaPage object
* Error
func GetRandom ¶
Get a list of random Wikipedia article titles.
**Note:: Random only gets articles from namespace 0, meaning no Category, User talk, or other meta-Wikipedia pages.
Keyword arguments:
* limit: The number of random pages returned (max of 10)
func Search ¶
Do a Wikipedia search for `query`.
Keyword arguments:
* _input: The query used to search Ex:"Who invented the lightbulb"
* limit: The maxmimum number of results returned. Use -1 to use default setting
* suggest: If True, return results and suggestion (if any) in a tuple. Fasle is defalt
Return:
* A slice of Wikipedia titles from the search engine
* Suggestion if `suggest` is being set True
* Error
func SetCacheDuration ¶
Change the max duration of the request responses exist in the Cache
func SetLanguage ¶
func SetLanguage(lang string)
Change the language of the API being requested. Set `prefix` to one of the two letter prefixes found on the list of all Wikipedia <http://meta.wikimedia.org/wiki/List_of_Wikipedias>. Then clear all of the cache
func SetMaxCacheMemory ¶
func SetMaxCacheMemory(n int)
Change the max number of the request responses stored in the Cache
func SetURL ¶ added in v1.0.1
func SetURL(url string)
Change the language of the API being requested. Set `prefix` to one of the two letter prefixes found on the list of all Wikipedia <http://meta.wikimedia.org/wiki/List_of_Wikipedias>. Then clear all of the cache
func SetUserAgent ¶
func SetUserAgent(user string)
Change the user-agent that you use to crawl Wikipedia data
func Suggest ¶
Get a Wikipedia search suggestion for `_input`.
Returns a string or "" if no suggestion was found.
func Summary ¶
func Summary(title string, numsentence int, numchar int, suggest bool, redirect bool) (string, error)
Return a string summary of a page
**Note:: This is a convenience wrapper - auto_suggest and redirect are enabled by default\
Keyword arguments:
* title: Title of the page you want to get the summary
* numsentence: If set, return the first `numsentence` sentences (can be no greater than 10).
* numchar: If set, return only the first `numchar` characters (actual text returned may be slightly longer).
* auto_suggest: Let Wikipedia find a valid page title for the query. Default is False
* redirect: Allow redirection without raising RedirectError. Defalt is True
Types ¶
This section is empty.