Async Mediawiki Python libary
Project description
async-mediawiki
An asynchronous python libary to get mediawiki content
Installation
It requires Python 3.5 or above and aiohttp
pip3 install async-mediawiki
Usage
import async_mediawiki as mediawiki
w = mediawiki.MediaWiki("https://en.wikipedia.org/w/api.php")
html = await w.get_html("Chemistry") #page html when rendered
md = await w.get_markdown("Chemistry") #markdown, what you see when editing a page
text = await w.get_text("Chemistry") #pure text without html and markdown
summary = await w.get_summary("Chemistry") #summary, usually a the first paragraph explaning the page
await w.close() #close the session
#login to the wiki to make changes under a specific user
await w.login("username", "password")
#create an account
await w.create_account("username", "password", userEmail="email (optional)", userRealName="real name (optional)")
#to edit a page or create it if it doesn't exist
await w.edit_page("Page Title", "My content", token="my edit token")
#edit token is anonymous when not specified, otherwise auto-generated as the logged in user if not given an explicit one
#you can also use this
w = mediawiki.MediaWiki()
print(await w.get_markdown("https://wiki.guildwars.com/api.php?action=query&titles=Ranger&prop=revisions&rvprop=content&format=json&formatversion=2"))
#the libary handles the URLs automatically when provided a base URL to the API
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
async_mediawiki-0.0.2.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for async_mediawiki-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09264faa865ed91f741c493b853a816868d564ce8c19c75337b2f59a1d04dc0e |
|
MD5 | 778d9e00d5ae9ef98d9998972c71ba2b |
|
BLAKE2b-256 | 77c8d5fbbb3427b104475a5dab4ca1f2de72ab236b99607770b9dd6b854fb9f4 |