goldsmith / Wikipedia

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

GuessedAtParserWarning: No parser was explicitly specified #264

Open Trilarion opened 3 years ago

Trilarion commented 3 years ago

I got the following warning when using wikipedia (version 1.4.0):

..py38\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 ("html5lib"). 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 ..py38\lib\site-packages\wikipedia\wikipedia.py. To get rid of this warning, pass the additional argument 'features="html5lib"' to the BeautifulSoup constructor.

which is probably related to how wikipedia uses BeautifulSoup. With BS one can choose a parser (https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser). Maybe instead of a warning one could include the selection of the parser in BS from wikipedia.

Luen commented 4 months ago

107