sections = [x.children[0].asText().strip() for x in r.children if
    isinstance(x, parser.Section)]
assert sections == ['1', '3']
How to parse/extract data from a mediawiki marked-up article via python