当前位置: 代码迷 >> 综合 >> Python-UserWarning: No parser was explicitly specified
  详细解决方案

Python-UserWarning: No parser was explicitly specified

热度:45   发布时间:2024-01-17 15:57:20.0

详细警告信息如下:

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.

分析器预警:没有显式指定解析器,所以我使用了这个系统中可用的最好的HTML解析器(“lxml”)。这通常不是问题,但是如果您在另一个系统上或在不同的虚拟环境中运行此代码,它可能会使用不同的解析器,并且表现不同

通过警告提示,我们指定HTML解析器

BeautifulSoup(res.text, "lxml")

 

解释器:参数值可以是:"lxml", "lxml-xml", "html.parser", or "html5lib", "html", "html5", "xml",建议命名一个特定的解析器,这样Beautiful Soup就可以跨平台和虚拟环境提供相同的结果

 

  相关解决方案