update ZhihuPageProcessor example

master
yihua.huang 2017-06-03 10:42:17 +08:00
parent 2d693580fc
commit bb0eb69acf
1 changed files with 3 additions and 3 deletions

View File

@ -16,9 +16,9 @@ public class ZhihuPageProcessor implements PageProcessor {
@Override
public void process(Page page) {
page.addTargetRequests(page.getHtml().links().regex("https://www\\.zhihu\\.com/question/\\d+/answer/\\d+.*").all());
page.putField("title", page.getHtml().xpath("//h2[@class='zm-item-title']/a/text()").toString());
page.putField("question", page.getHtml().xpath("//div[@id='zh-question-detail']//tidyText()").toString());
page.putField("answer", page.getHtml().xpath("//div[@id='zh-question-answer-wrap']//div[@class='zm-editable-content']/tidyText()").toString());
page.putField("title", page.getHtml().xpath("//h1[@class='QuestionHeader-title']/text()").toString());
page.putField("question", page.getHtml().xpath("//div[@class='QuestionRichText']//tidyText()").toString());
page.putField("answer", page.getHtml().xpath("//div[@class='QuestionAnswer-content']/tidyText()").toString());
if (page.getResultItems().get("title")==null){
//skip this page
page.setSkip(true);