goldsmith / Wikipedia

A Pythonic wrapper for the Wikipedia API
https://wikipedia.readthedocs.org/
MIT License
2.89k stars 519 forks source link

About a weird fact of page function #299

Closed ShallJaiden closed 2 years ago

ShallJaiden commented 2 years ago
search = wikipedia.search("Elon musk")
print(search[0])
page = wikipedia.page("Elon Musk")
print(page.url)

and it gave me this

Elon Musk
Traceback (most recent call last):
  File "/Users/shalljaiden/PycharmProjects/discord/test.py", line 6, in <module>
    page = wikipedia.page("Elon Musk")
  File "/Users/shalljaiden/PycharmProjects/discord/venv/lib/python3.8/site-packages/wikipedia/wikipedia.py", line 276, in page
    return WikipediaPage(title, redirect=redirect, preload=preload)
  File "/Users/shalljaiden/PycharmProjects/discord/venv/lib/python3.8/site-packages/wikipedia/wikipedia.py", line 299, in __init__
    self.__load(redirect=redirect, preload=preload)
  File "/Users/shalljaiden/PycharmProjects/discord/venv/lib/python3.8/site-packages/wikipedia/wikipedia.py", line 345, in __load
    raise PageError(self.title)
wikipedia.exceptions.PageError: Page id "e on musk" does not match any pages. Try another id!

but If I change the argument like:

search = wikipedia.search("chopin")
print(search[0])
page = wikipedia.page("Frédéric Chopin")
print(page.url)

it worked perfectly

Frédéric Chopin
https://en.wikipedia.org/wiki/Fr%C3%A9d%C3%A9ric_Chopin

what's the matter with this?

ShallJaiden commented 2 years ago

it seems that the page function "occasionally" works

ShallJaiden commented 2 years ago

auto_suggest=False , add it to your page function