新人请教一个beautifulsoup运行的错误问题

Andy.lee 2019-04-21 11:07:12
每次运行beautifulsoup时都会提示这个错误
UserWarning: 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 17 of the file E:/mypy/pa/one.py. To get rid of this warning, pass the additional argument 'features="lxml"' to the BeautifulSoup constructor.

bsObj = BeautifulSoup(html.read())
翻译后是
用户警告:没有明确指定解析器,所以我在这个系统中使用最好的可用的HTML解析器(“lxml”)。这通常不是问题,但是如果您在另一个系统或不同的虚拟环境中运行此代码,它可能会使用不同的解析器并表现出不同的行为。

导致此警告的代码位于文件E:/mypy/pa/one.py的第17行。要消除此警告,请将附加参数“features="lxml "”传递给美化的组构造函数。

bsObj =美化输出(html.read())

可是在urlopen后面加上‘lxml’后就直接不能运行了,请问这个怎么解决
...全文
646 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Andy.lee 2019-04-21
  • 打赏
  • 举报
回复
有人吗,谢谢大家了
Andy.lee 2019-04-21
  • 打赏
  • 举报
回复
哦哦哦,是的,我加在urlopen后面了,🙏
qq_39736804 2019-04-21
  • 打赏
  • 举报
回复 1
不是在urlopen后面加lxml
把17行改成bsObj=BeautifulSoup(html.read(),'lxml')即可

37,721

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧