I’m writing a program where I get information from a page and put it in excel file.
The problem is, I don’t find a way to search for the tag with the specific info.
Here is my code(so far):
private void getAll() throws IOException {
for (int i = 0;i<250;i++){
URL vurl = new URL("http://www.bamart.be/nl/artists/detail/" + i);
BufferedReader reader = new BufferedReader(new InputStreamReader(vurl.openStream()));
String line;
while ((line = reader.readLine()) != null){
if (line.equalsIgnoreCase("<div class=\"subcontent\">"){
System.out.println("Found info!");
}
printInfo(line,i);
}
}
}
private void printInfo(String info,int i){
System.out.println("/***********************************************/");
System.out.println("************\t" + info + "**********************/");
System.out.println("/************" +" Artist page:" + i + " of 999 **********************/" );
}
The println doesn’t come up, but it is in the html file.
This if statement is checking for exact equality (ignoring case) however there could be other content on that line including whitespace for example.
What you might want instead would be something like