2

我无法让 lxml 与漂亮的汤一起使用。在 osx 10.8.4 上运行。要安装 lxml,我做了端口安装 py25-lxml,它安装得很好。现在,当我尝试将 lxml 与 Beautiful Soup 一起使用时出现此错误:

Traceback (most recent call last):
  File "********.py", line 13, in <module>
    soup = BeautifulSoup(urllib2.urlopen(url).read(), 'lxml')
  File "/Users/********/********/bs4/__init__.py", line 155, in __init__
    % ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml.
Do you need to install a parser library?

不确定这是否是问题的一部分,但我无法导入 lxml.etree

有没有其他人让 lxml 在 osx 上处理漂亮的汤?

另外,也许我可以尝试使用不同的 html 解析器。有人对其他解析器有建议吗?

4

1 回答 1

0

From the lxml website:

If this fails attempt to build it yourself http://lxml.de/build.html#building-lxml-on-macos-x

This may not work so don't rely on it

Otherwise there are other parsers such as lxml.html (should work with lxml) and a few others that I'm not sure of.

于 2013-08-24T02:37:56.583 回答