From 51df09ccf0b0b6c0c0cb6d47e64f3937437f8bc5 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 31 May 2014 21:02:16 -0400 Subject: [PATCH] Really minor documentation fixes. --- README.rst | 6 ++++-- docs/integration.rst | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 5b4cfe1..1b25c42 100644 --- a/README.rst +++ b/README.rst @@ -123,19 +123,21 @@ If you're using Pywikipedia_, your code might look like this:: import mwparserfromhell import wikipedia as pywikibot + def parse(title): site = pywikibot.getSite() page = pywikibot.Page(site, title) text = page.get() return mwparserfromhell.parse(text) -If you're not using a library, you can parse templates in any page using the -following code (via the API_):: +If you're not using a library, you can parse any page using the following code +(via the API_):: import json import urllib import mwparserfromhell API_URL = "http://en.wikipedia.org/w/api.php" + def parse(title): data = {"action": "query", "prop": "revisions", "rvlimit": 1, "rvprop": "content", "format": "json", "titles": title} diff --git a/docs/integration.rst b/docs/integration.rst index 78810b8..a09334d 100644 --- a/docs/integration.rst +++ b/docs/integration.rst @@ -11,19 +11,21 @@ If you're using Pywikipedia_, your code might look like this:: import mwparserfromhell import wikipedia as pywikibot + def parse(title): site = pywikibot.getSite() page = pywikibot.Page(site, title) text = page.get() return mwparserfromhell.parse(text) -If you're not using a library, you can parse templates in any page using the -following code (via the API_):: +If you're not using a library, you can parse any page using the following code +(via the API_):: import json import urllib import mwparserfromhell API_URL = "http://en.wikipedia.org/w/api.php" + def parse(title): raw = urllib.urlopen(API_URL, data).read() res = json.loads(raw)