|
|
@@ -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} |
|
|
|