简体   繁体   English

如何使用样板从HTML获取文章的主要内容?

[英]How to get the main content of an article from HTML using boilerplate?

I am trying to get the main content of an article from an HTML using boilerpipe code. 我正在尝试使用样板代码从HTML获取文章的主要内容。

Downloaded the latest jars from here . 这里下载最新的罐子。

I am trying to use the following code: 我正在尝试使用以下代码:

String article = "";
try {
    article = ArticleExtractor.INSTANCE.getText(url);   
    System.out.println("Article ++++ >>" + article);    
} catch (BoilerpipeProcessingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

But this returns an empty string for every URL . 但这会为每个URL返回一个空字符串 Can anyone help me on this? 谁可以帮我这个事?

Have you tried to pass the HTML itself instead of the url? 您是否尝试过传递HTML本身而不是URL? Or maybe there is a problem with the way your url strings are formatted. 也许您的url字符串格式设置方式存在问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM