use of org.jaxen.jdom.JDOMXPath in project Asqatasun by Asqatasun.
the class KbCsvMojo method getUrls.
private List<String> getUrls(String url) throws JDOMException, JaxenException, IOException {
SAXBuilder builder = new SAXBuilder();
EntityResolver resolver = new XhtmlEntityResolver();
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
builder.setEntityResolver(resolver);
Document document = builder.build(new URL(url));
XPath xpath = new JDOMXPath("//*[@id='resultat']//*[@href]/@href");
List<Attribute> results = xpath.selectNodes(document);
List<String> urls = new ArrayList<String>();
for (Attribute attr : results) {
urls.add(attr.getValue());
}
return urls;
}
Aggregations