I'm trying to have a web crawler return true when it finds a given word on a webpage. The return true statement never runs though so I can't use it properly. Anyone have a simply way to do this? Thanks
public static boolean keywordSearch(String url, String keyword){
String strTemp = "";
try {
URL my_url = new URL(url);
BufferedReader br = new BufferedReader(new InputStreamReader(my_url.openStream()));
while(null != (strTemp = br.readLine())){
if (strTemp.contains(keyword)){
return true;
}
}
} catch (Exception ex) {
System.out.println("Error: " + ex.getMessage());
}
return false;
}
Aucun commentaire:
Enregistrer un commentaire