如何摆脱BeautifulSoup用户警告? [英] How to get rid of BeautifulSoup user warning?
本文介绍了如何摆脱BeautifulSoup用户警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我安装BeautifulSoup,每当我跑我的Python在cmd中后,这个警告出来。
<$p$p><$c$c>D:\\Application\\python\\lib\\site-packages\\beautifulsoup4-4.4.1-py3.4.egg\\bs4\\__init__.py:166:UserWarning:没有解析器明确指定的,所以我用最好的
提供HTML解析器该系统(html.parser)。这通常不是一个
问题,但如果在其他系统上运行该code,或在不同的
虚拟环境中,可以使用不同的解析器和表现不同。要摆脱这种警告,更改此: BeautifulSoup([您的标记])为此: BeautifulSoup([您的标记],html.parser)
我不理想,为什么它出来,以及如何解决它。
解决方案
这是pretty错误消息作了明确规定。你必须改变这样的:
BeautifulSoup(...)
要像这样:
BeatifulSoup(...,html.parser)
After I installed BeautifulSoup, Whenever I run my Python in cmd, this warning comes out.
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")
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")
这篇关于如何摆脱BeautifulSoup用户警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文