DefQaListLink implements QaListLink, Serializable { @Override public List<String> getQaLinks(String listUrl) { logger.info("查询：" + listUrl); Set<String> urlLinks = new HashSet<String>(); Document doc = HtmlDocumentUtil.urlToDocument(listUrl); if (HtmlDocumentUtil.validateDocument(doc)) { Elements links = doc.select("a[href]"); String parseUrl; try { for (Element link : links) { parseUrl = link.attr("abs:href").trim(); if(StringUtils.isEmpty(parseUrl)) continue; if (parseUrl.contains(NANGJING_QA_LINK_RULE)) { urlLinks.add(parseUrl); } } } catch (PatternSyntaxException e) { return new ArrayList<String>(urlLinks); } } return new ArrayList<String>(urlLinks); }  @Override List<String> getQaLinks(String listUrl);  }
@Test public void testGetQaLinks() throws Exception { QaListLink qaListLink = new DefQaListLink(); qaListLink.getQaLinks("http: }