我正在使用python构建一个应用程序,其中包括从RSS提要获取新闻文章。作为我项目的一部分,我决定使用boilerpipe从文章所在的html页面中提取文章内容。
尽管boilerpipe最初是为java编写的,但它也被移植到了python。你可以在github上看到它的页面:https://github.com/misja/python-boilerpipe
问题是,我在尝试使用以下命令导入它时出现异常:
from boilerpipe.extract import Extractor我得到的错误是:
Traceback (most recent call last):
File "", line 1, in
File "build\bdist.win32\egg\boilerpipe\extract__init__.py", line 12, in
File "C:\Python26\lib\site-packages\jpype_jclass.py", line 54, in JClass
raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
jpype._jexception.ExceptionPyRaisable: java.lang.Exception: Class
de.l3s.boilerpipe.sax.HTMLHighlighter not found可能导致此问题的原因是什么?我如何解决它?
发布于 2015-03-10 01:16:50
这在我的Mac 10.8.5和Python 2.7.9上是有效的:
pip install JPype1 # to install https://pypi.python.org/pypi/JPype1
pip install charade
git clone https://github.com/misja/python-boilerpipe.git
cd python-boilerpipe
sudo python setup.py install然后,您应该能够在python控制台中执行以下操作
>>> from boilerpipe.extract import Extractor
>>> extractor = Extractor(extractor='ArticleExtractor', url="http://en.wikipedia.org/wiki/Main_Page")
>>> print extractor.getText()发布于 2012-09-16 01:19:31
你缺少锅炉管道java包安装,你可以在这里找到它- http://code.google.com/p/boilerpipe/downloads/list
您只安装了python boilerpipe wrapper。
发布于 2014-10-22 02:05:41
下面是最适合我的方法:
git clone https://github.com/misja/python-boilerpipe.git
cd python-boilerpipe
sudo python setup.py install您可能需要执行以下操作:
)
但是,您不必安装boilerpipe jar,因为安装程序会为您加载该文件。
我尝试从pip安装python boilerpipe,但是没有成功。我成功地运行了样板java代码,但一直收到同样的错误。
https://stackoverflow.com/questions/9352259
复制相似问题