Cómo obtener información del contenido de la etiqueta en el código fuente de una página web
/**
* @param args
* @throws URISyntaxException
*/
public static void main(String[] args) lanza una excepción {
URL url = nueva URL("/");
Lector de InputStreamReader = nuevo InputStreamReader(url.openStream( ));
BufferedReader br = new BufferedReader(lector);
String s = null;
while((s=br.readLine())! out.println(s);
}
}
br.close();
lector.close();
}
cadena estática pública GetContent(String html) {
//String html = "
- 1.jeje < li< gt;2.hi
- 3.hei
Cadena ss = ">[^<]+<";
String temp = null;
Patrón pa = Pattern.compile(ss);
Matcher ma = null;
ma = pa.matcher( html);
while(ma.find()){
temp = ma.group();
if( temp!=null){
if(temp.startsWith(">")){
temp = temp.substring(1);
}
si (temp.endsWith("<")){
temp = temp.substring(0, temp.length()-1);
}
si(! temp.equalsIgnoreCase("")){
//System.out.println(temp);
Devuelve temperatura;
}
}
}
}
Devuelve nulo;
}
}