-
Notifications
You must be signed in to change notification settings - Fork 78
Usage
Steve edited this page Sep 20, 2017
·
32 revisions
Simply import wptools to get started.
>>> import wptools
You can instantiate one of the following:
- Page object to get info about a Mediawiki page
- Category object to get info about Mediawiki categories
- Site object to get Wikimedia site info
The following apply to all wptools objects...
Object data echoes automatically. You can turn that off with silent=True
:
>>> page = wptools.page(silent=True)
Request details echo to stderr with verbose=True
:
>>> page = wptools.page(verbose=True)
All request actions support setting proxy
and timeout
(in seconds):
>>> page.get(proxy='http://example.com:80', timeout=5)
You can skip request actions using skip
:
>>> page = wptools.page(skip=['claims', 'imageinfo'])
All request actions are cached:
page.cache
{
claims: {query, response, info},
imageinfo: {query, response, info},
parse: {query, response, info},
query: {query, response, info},
rest: {query, response, info},
wikidata: {query, response, info}
}
category.cache
{
category: {query, response, info},
}
site.cache
{
siteinfo: {query, response, info},
sitematrix: {query, response, info},
sitevisitors: {query, response, info}
}
The wptools
user-agent will look like this:
wptools/<version> (https://github.com/siznax/wptools) <libs>