Search code examples
pythonwikipediawikipedia-apipywikibot

How do I get the HTML of a wiki page with Pywikibot?


I'm using pywikibot-core, and I used before another python Mediawiki API wrapper as Wikipedia.py (which has a .HTML method). I switched to pywikibot-core 'cause I think it has many more features, but I can't find a similar method. (beware: I'm not very skilled).


Solution

  • I'll post here user283120 second answer, more precise than the first one:

    Pywikibot core doesn't support any direct (HTML) way to interact to Wiki, so you should use API. If you need to, you can do it easily by using urllib2.

    This is an example I used to get HTML of a wiki page in commons: import urllib2 ... url = "https://commons.wikimedia.org/wiki/" + page.title().replace(" ","_") html = urllib2.urlopen(url).read().decode('utf-8')