如何为python安装解析器库[重复]

Posted

技术标签:

【中文标题】如何为python安装解析器库[重复]【英文标题】:How to install a parser library for python [duplicate] 【发布时间】:2019-12-16 04:46:00 【问题描述】:

我得到:

Couldn't find a tree builder with the features you requested: parser.html. Do you need to install a parser library?

每当我尝试解析我的页面时。请大家帮忙,我还不是很擅长python。

import requests
from bs4 import BeautifulSoup

response = requests.get("http://***.com/questions")
soup = BeautifulSoup(response.text,"parser.html")
questions = soup.select(".question-summary")

【问题讨论】:

【参考方案1】:

解析器应该是“html.parser”而不是“parser.html”

详情请参考美汤documentation。

【讨论】:

请允许您只获取问题文本[0]【参考方案2】:

使用'html.parser' 代替'parser.html'。这可能有效。

如果没有,请尝试:"html5lib"

【讨论】:

以上是关于如何为python安装解析器库[重复]的主要内容,如果未能解决你的问题,请参考以下文章