jellyfishhuang jellyfishhuang - 8 months ago 85
Python Question

How to get rid of BeautifulSoup user warning?

After I installed BeautifulSoup, Whenever I run my Python in cmd, this warning comes out.

UserWarning: 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.

To get rid of this warning, change this:

BeautifulSoup([your markup])

to this:

BeautifulSoup([your markup], "html.parser")

I have no ideal why it comes out and how to solve it.


It's pretty clearly stated in the error message. You have to change something like this:

BeautifulSoup( ... )

To something like this:

BeatifulSoup( ..., "html.parser")