Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error in Python using wikipedia module: wikipedia.exceptions.PageError: Page id "harry plotter" does not match any pages. Try another id

newbie in Python here

when I run this simple code (to load Harry Potter page and simply print it)
it returns me Error with the wrong name I wanted to search (harry plotter)
can anyone tell me how to fix? thank you!

import wikipedia

page = wikipedia.page("Harry Potter")

print(page.summary)

Error message:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Traceback (most recent call last):
File "C:\Users\Lidor\PycharmProjects\pythonProject\search_engine.py", line 7, in <module>
  page = wikipedia.page(search[0])
File "C:\Users\Lidor\PycharmProjects\pythonProject\venv\lib\site- 
  packages\wikipedia\wikipedia.py", line 276, in page
  return WikipediaPage(title, redirect=redirect, preload=preload)
File "C:\Users\Lidor\PycharmProjects\pythonProject\venv\lib\site- 
  packages\wikipedia\wikipedia.py", line 299, in __init__
  self.__load(redirect=redirect, preload=preload)
File "C:\Users\Lidor\PycharmProjects\pythonProject\venv\lib\site- 
  packages\wikipedia\wikipedia.py", line 345, in __load
  raise PageError(self.title)
  wikipedia.exceptions.PageError: Page id "harry plotter" does not match any pages. Try 
    another id!

>Solution :

This appears to be a strange result of auto_suggest being set by default. If you do

wikipedia.page("Harry Potter", auto_suggest=False)

It works fine. Otherwise it autocompletes potter to plotter, hence the error.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading