2014-09-06 26 views
0

当试图刮掉一些与BeautifulSoup和Django返回:Django的BeautifulSoup FeatureNotFound

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

的这是在停止代码行是:

urlContent = urllib2.urlopen(url).read()  
soup = BeautifulSoup(''.join(urlContent)) 

我已经尝试了不同的方式来进口:

from bs4 import BeautifulSoup 
import BeautifulSoup 
etc, etc. 

我在一个残端,我不知道这是什么套管或为什么。在.py中测试时效果很好,所以我只能假设它是Django。任何已知的修复/解决办法?

Traceback: 
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response 
    114.      response = wrapped_callback(request, *callback_args, **callback_kwargs) 
File "D:\django\bin\project\Main\functions.py" in mangasee 
    44. soup = BeautifulSoup(''.join(urlContent)) 
File "D:\django\bin\project\Main\bs4\__init__.py" in __init__ 
    152.      % ",".join(features)) 

Exception Type: FeatureNotFound at /moderator/ 
Exception Value: Couldn't find a tree builder with the features you requested: html,fast. Do you need to install a parser library? 
+0

请显示完整的回溯和发生错误的行。谢谢。 – alecxe 2014-09-06 01:48:34

+0

@alecxe加入了什么 – user1043816 2014-09-06 02:04:24

+0

安装'html5lib'有帮助吗? ('pip install html5lib') – alecxe 2014-09-06 02:19:10

回答

1

从错误信息中可以明显看出Python无法找到bs工作所需的HTML解析器。 BeautifulSoup支持许多解析器,例如Python标准库中的HTML解析器。从您提供的代码中,我看不出为什么没有找到解析器。有时候是因为bs的版本与您使用的Python版本不匹配。请参阅本网站http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup了解更多信息。

+0

尽管我运行的是python 2.7,但似乎django只接受BS3。谢谢你的文件! – user1043816 2014-09-06 02:38:02