完整报错如下:
UserWarning: 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.
报错代码如下:
bs = BeautifulSoup(response.text)
说明:python在使用BeautifulSoup的时候,运行没有问题,但是会提示No parser was explicitly specified。在百度上查了一下,发现是BeautifulSoup运行的时候没有指定的解释器,默认使用了html5lib。
解决办法:
1、先使用pip install 安装html5lib
pip install html5lib
2、在报错代码里添加"html5lib"
修改后的代码如下:
bs = BeautifulSoup(response.text, "html5lib")