本文整理汇总了Java中de.jetwick.snacktory.JResult类的典型用法代码示例。如果您正苦于以下问题:Java JResult类的具体用法?Java JResult怎么用?Java JResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JResult类属于de.jetwick.snacktory包,在下文中一共展示了JResult类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFeedPageFromUrl
import de.jetwick.snacktory.JResult; //导入依赖的package包/类
public FeedPage getFeedPageFromUrl(String url, FeedItem feedItem) {
logger.debug("HTML and text extraction for url : {} started", url);
FeedPage feedPage = new FeedPage();
try {
String html = Utils.getStringFromStream(new URL(url).openConnection().getInputStream());
HtmlFetcher fetcher = new HtmlFetcher();
JResult res = fetcher.fetchAndExtract(url, 30000, true);
setFeedItemdebug(feedPage, feedItem);
setFeeddebug(feedPage, feedItem.getParentFeed());
feedPage.setBestGuessRelevantText(res.getText());
feedPage.setDecodedPubTime(Utils.convertToDateTime(feedItem.getPubDate()).toString());
feedPage.setFullText(html);
return feedPage;
} catch (Exception e) {
logger.debug("Exception : {}", e.getLocalizedMessage());
return null;
}
}
示例2: parseGeneral
import de.jetwick.snacktory.JResult; //导入依赖的package包/类
@ParseRule(priority = 999, uriPattern = ".*")
public void parseGeneral() throws Exception {
JResult jres = extractor.extractContent(getPage());
GeneralResultAbstractItem item = new GeneralResultAbstractItem();
item.setUrl(getUrl());
item.setTitle(jres.getTitle());
item.setDate(jres.getDate());
item.setContent(jres.getText());
addItem(item);
}
示例3: testSnacktoryParser
import de.jetwick.snacktory.JResult; //导入依赖的package包/类
@Test
public void testSnacktoryParser() throws Exception {
JResult jres = extractor.extractContent(html);
String txt = jres.getText().trim();
Assert.assertTrue(txt.startsWith(" “互联网+农业”绝不只是发展农村电商。互"));
Assert.assertTrue(txt.endsWith("这也正是新时期“三农”的希望和未来所在。"));
}
示例4: parseGeneral
import de.jetwick.snacktory.JResult; //导入依赖的package包/类
@Override
@ParseRule(uriPattern = "dummy_url", priority = 1)
public void parseGeneral() throws Exception {
JResult jres = extractor.extractContent(getPage());
GeneralResultAbstractItem item = new GeneralResultAbstractItem();
item.setUrl(getUrl());
item.setTitle(jres.getTitle());
item.setDate(jres.getDate());
item.setContent(jres.getText());
addItem(item);
addItem(item);
followUrl("another_url");
setStatus(ProcessStatus.OK);
}
示例5: parseArticle
import de.jetwick.snacktory.JResult; //导入依赖的package包/类
private String parseArticle(String url){
HtmlFetcher fetcher = new HtmlFetcher();
JResult res;
try {
res = fetcher.fetchAndExtract(url, 10000, true); //I don't know what it means, need to read docs/source
title = res.getTitle();
return title + " | " + res.getText();
} catch (Exception e) {
e.printStackTrace();
}
return "";
}