update ZhihuPageProcessor example
parent
2d693580fc
commit
bb0eb69acf
|
@ -16,9 +16,9 @@ public class ZhihuPageProcessor implements PageProcessor {
|
||||||
@Override
|
@Override
|
||||||
public void process(Page page) {
|
public void process(Page page) {
|
||||||
page.addTargetRequests(page.getHtml().links().regex("https://www\\.zhihu\\.com/question/\\d+/answer/\\d+.*").all());
|
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("title", page.getHtml().xpath("//h1[@class='QuestionHeader-title']/text()").toString());
|
||||||
page.putField("question", page.getHtml().xpath("//div[@id='zh-question-detail']//tidyText()").toString());
|
page.putField("question", page.getHtml().xpath("//div[@class='QuestionRichText']//tidyText()").toString());
|
||||||
page.putField("answer", page.getHtml().xpath("//div[@id='zh-question-answer-wrap']//div[@class='zm-editable-content']/tidyText()").toString());
|
page.putField("answer", page.getHtml().xpath("//div[@class='QuestionAnswer-content']/tidyText()").toString());
|
||||||
if (page.getResultItems().get("title")==null){
|
if (page.getResultItems().get("title")==null){
|
||||||
//skip this page
|
//skip this page
|
||||||
page.setSkip(true);
|
page.setSkip(true);
|
||||||
|
|
Loading…
Reference in New Issue