ciao ragazzi vi posto questo codice:
URL url = new URL("http://www.sito.it");
BufferedInputStream page = new BufferedInputStream(url.openStream());
Tidy tidy = new Tidy();
tidy.setQuiet(true);
tidy.setShowWarnings(false);
Document response = tidy.parseDOM(page, null);
XPathFactory factory = XPathFactory.newInstance();
XPath xPath = factory.newXPath();
String pattern = "//a[@class='link']/@href";
NodeList nodes = (NodeList) xPath.evaluate(pattern, response, XPathConstants.NODESET);
for (int i = 0; i < nodes.getLength(); i++) {
System.out.println((String) nodes.item(i).getNodeValue());
}
il valore di nodes è 0 e quindi nn mi visualizza niente come devo fare??

Rispondi quotando