Extract template arguments in Python from MediaWiki's API wikitext Extract template arguments in Python from MediaWiki's API wikitext json json

Extract template arguments in Python from MediaWiki's API wikitext


I'm sure the regex and final splitting could be more efficient, but this gets the job done for what you asked.

import urllib2import redata = urllib2.urlopen('http://marvel.wikia.com/api.php?action=query&prop=revisions&titles=All-New%20X-Men%20Vol%201%201&rvprop=content')regex = re.compile('(Writer1_1|Penciler1_1)')for line in data.read().split('|'):    if regex.search(line):        #assume everything after = is the full name        print ' '.join(line.split()[2:])