错误提示
Warning (from warnings module):
File “C:/Users/ASUS/小牛试刀+bsoup4除标签.py”, line 8
bf = BeautifulSoup(html)
GuessedAtParserWarning: No parser was explicitly specified, so I’m using the best available HTML parser for this system (“lxml”). 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 8 of the file C:/Users/ASUS/小牛试刀+bsoup4除标签.py. To get rid of this warning, pass the additional argument ‘features=“lxml”’ to the BeautifulSoup constructor.
意思是
警告(来自警告模块):
文件“C:/Users/ASUS/小牛试刀+B组4除标签.py”,第8行
bf=BeautifulSoup(html)
GuessedAtParserWarning:没有显式指定解析器,所以我使用了这个系统中可用的最好的HTML解析器(“lxml”)。这通常不是问题,但是如果您在另一个系统上或在不同的虚拟环境中运行此代码,它可能会使用不同的解析器并表现出不同的行为。
导致此警告的代码位于文件C:/Users/ASUS的第8行/小牛试刀+B组4除标签。要消除此警告,请将附加参数’features=“lxml”'传递给BeautifulSoup构造函数。
解决办法
在错误提示的那一行代码中加解析器传递给BeautifulSoup构造函数。
错误代码
bf=BeautifulSoup(html)
正确代码
bf=BeautifulSoup(html,'lxml')