@Test public void testGetContent() throws Exception { QaContentLink contentLink = new DefQaContentLink(); Model model = contentLink.getContent("http: System.out.println(model.getAnswer()); System.out.println("q:" + model.getQuestion()); System.out.println("g:"+model.getGistLink()); }
@Override public Model getContent(String contentUrl) { Document doc = HtmlDocumentUtil.urlToDocument(contentUrl); if (HtmlDocumentUtil.validateDocument(doc)) { Model model = new Model(); model.setQaLink(contentUrl); Elements elements = doc.select(CONTENT_SELECT); model.setQuestion(elements.get(1).text()); elements = doc.select(ANSWER_SELECT); model.setAnswer(elements.get(0).text()); elements = doc.select(GIST_SELECT); model.setGistLink(elements.get(0).text()); return model; } return null; }
DefQaContentLink implements QaContentLink { @Override public Model getContent(String contentUrl) { Document doc = HtmlDocumentUtil.urlToDocument(contentUrl); if (HtmlDocumentUtil.validateDocument(doc)) { Model model = new Model(); model.setQaLink(contentUrl); Elements elements = doc.select(CONTENT_SELECT); model.setQuestion(elements.get(1).text()); elements = doc.select(ANSWER_SELECT); model.setAnswer(elements.get(0).text()); elements = doc.select(GIST_SELECT); model.setGistLink(elements.get(0).text()); return model; } return null; } }
DefQaContentLink implements QaContentLink { @Override public Model getContent(String contentUrl) { Document doc = HtmlDocumentUtil.urlToDocument(contentUrl); if (HtmlDocumentUtil.validateDocument(doc)) { Model model = new Model(); model.setQaLink(contentUrl); Elements elements = doc.select(CONTENT_SELECT); model.setQuestion(elements.get(1).text()); elements = doc.select(ANSWER_SELECT); model.setAnswer(elements.get(0).text()); elements = doc.select(GIST_SELECT); model.setGistLink(elements.get(0).text()); return model; } return null; }  }
DefQaContentLink implements QaContentLink { @Override public Model getContent(String contentUrl) { Document doc = HtmlDocumentUtil.urlToDocument(contentUrl); if (HtmlDocumentUtil.validateDocument(doc)) { Model model = new Model(); model.setQaLink(contentUrl); Elements elements = doc.select(CONTENT_SELECT); model.setQuestion(elements.get(1).text()); elements = doc.select(ANSWER_SELECT); model.setAnswer(elements.get(0).text()); elements = doc.select(GIST_SELECT); model.setGistLink(elements.get(0).text()); return model; } return null; }  @Override Model getContent(String contentUrl); }
DefQaContentLink implements QaContentLink { @Override public Model getContent(String contentUrl) { Document doc = HtmlDocumentUtil.urlToDocument(contentUrl); if (HtmlDocumentUtil.validateDocument(doc)) { Model model = new Model(); model.setQaLink(contentUrl); Elements elements = doc.select(CONTENT_SELECT); model.setQuestion(elements.get(1).text()); elements = doc.select(ANSWER_SELECT); model.setAnswer(elements.get(0).text()); elements = doc.select(GIST_SELECT); model.setGistLink(elements.get(0).text()); return model; } return null; }  @Override Model getContent(String contentUrl);  }