【发布时间】:2016-02-04 08:08:02
【问题描述】:
安装 BeautifulSoup 后,每当我在 cmd 中运行我的 Python 时,都会出现此警告。
D:\Application\python\lib\site-packages\beautifulsoup4-4.4.1-py3.4.egg\bs4\__init__.py:166:
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")
我不知道为什么会出现以及如何解决它。
【问题讨论】:
-
该消息正在告诉您确切的操作:
BeautifulSoup([your markup], "html.parser")。你这样做了,看看你的输出是什么? BeautifulSoup 试图让您的生活更轻松。听汤。 :) -
将
soup = BeautifulSoup(html)之类的代码更改为soup = BeautifulSoup(html, "html.parser")。
标签: python beautifulsoup user-warning