import wikipedia wikipedia.set_lang("en") # wikipedia # ------------------------------------------------------------------------ def get_wikipage(pagename): # get wikipedia page content by name of the page print(pagename) try: results = wikipedia.search(pagename, results=1, suggestion=False) try: pagename = results[0] except IndexError: # if there is no suggestion or search results, the page doesn't exist raise wikipedia.PageError(pagename) return wikipedia.WikipediaPage(pagename, redirect=True, preload=True) except wikipedia.exceptions.DisambiguationError as e: print(e.options) page = '' return page