Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python wikipedia module issue #25

Open
DickieTheProgrammer opened this issue Apr 12, 2022 Discussed in #21 · 2 comments
Open

Python wikipedia module issue #25

DickieTheProgrammer opened this issue Apr 12, 2022 Discussed in #21 · 2 comments

Comments

@DickieTheProgrammer
Copy link

Discussed in #21

Originally posted by DickieTheProgrammer September 1, 2021
In your example of "bass", I get an entirely different disambiguation list than what's shown here. It appears to search for "band." Searching for "band" appears to search for "can".

>>> w.page('bass')
C:\Users\payne\AppData\Local\Programs\Python\Python39\lib\site-packages\wikipedia\wikipedia.py:389: GuessedAtParserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.

The code that caused this warning is on line 389 of the file C:\Users\payne\AppData\Local\Programs\Python\Python39\lib\site-packages\wikipedia\wikipedia.py. To get rid of this warning, pass the additional argument 'features="html.parser"' to the BeautifulSoup constructor.

  lis = BeautifulSoup(html).find_all('li')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\payne\AppData\Local\Programs\Python\Python39\lib\site-packages\wikipedia\wikipedia.py", line 276, in page
    return WikipediaPage(title, redirect=redirect, preload=preload)
  File "C:\Users\payne\AppData\Local\Programs\Python\Python39\lib\site-packages\wikipedia\wikipedia.py", line 299, in __init__
    self.__load(redirect=redirect, preload=preload)
  File "C:\Users\payne\AppData\Local\Programs\Python\Python39\lib\site-packages\wikipedia\wikipedia.py", line 367, in __load
    self.__init__(redirects['to'], redirect=redirect, preload=preload)
  File "C:\Users\payne\AppData\Local\Programs\Python\Python39\lib\site-packages\wikipedia\wikipedia.py", line 299, in __init__
    self.__load(redirect=redirect, preload=preload)
  File "C:\Users\payne\AppData\Local\Programs\Python\Python39\lib\site-packages\wikipedia\wikipedia.py", line 393, in __load
    raise DisambiguationError(getattr(self, 'title', page['title']), may_refer_to)
wikipedia.exceptions.DisambiguationError: "Band" may refer to:
Bánd
Band, Iran
Band, Mureș
Band-e Majid Khan
Band (surname)
...

and 

>>> w.page('band')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\payne\AppData\Local\Programs\Python\Python39\lib\site-packages\wikipedia\wikipedia.py", line 276, in page
    return WikipediaPage(title, redirect=redirect, preload=preload)
  File "C:\Users\payne\AppData\Local\Programs\Python\Python39\lib\site-packages\wikipedia\wikipedia.py", line 299, in __init__
    self.__load(redirect=redirect, preload=preload)
  File "C:\Users\payne\AppData\Local\Programs\Python\Python39\lib\site-packages\wikipedia\wikipedia.py", line 393, in __load
    raise DisambiguationError(getattr(self, 'title', page['title']), may_refer_to)
wikipedia.exceptions.DisambiguationError: "can" may refer to:
Aluminum can
Drink can
Oil can
...</div>
@pranav-05
Copy link

Did you got any solution?
If yes please tell me also
Thank you

@DickieTheProgrammer
Copy link
Author

Not yet. I see the project seems to be kind of dead. I was going to just review the open PRs to see if anyone addressed it before I dig in myself. Glad to see someone's interested!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants