removed error message spam
This commit is contained in:
@@ -39,7 +39,7 @@ public class CrawlBranch {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("ERROR -- error in out http request : " + e);
|
//System.out.println("ERROR -- error in out http request : " + e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ public class CrawlBranch {
|
|||||||
*/
|
*/
|
||||||
public int searchForWord(String word) {
|
public int searchForWord(String word) {
|
||||||
if (this.htmlDocument == null){
|
if (this.htmlDocument == null){
|
||||||
System.out.println("ERROR -- call crawl before searhing");
|
//System.out.println("ERROR -- call crawl before searhing");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
System.out.printf("Searching for %s...", word);
|
System.out.printf("Searching for %s...", word);
|
||||||
|
|||||||
@@ -143,52 +143,4 @@ public class WebCrawler {
|
|||||||
this.successPages = 0;
|
this.successPages = 0;
|
||||||
this.amountFound = 0;
|
this.amountFound = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
|
||||||
// Scanner input = new Scanner(System.in);
|
|
||||||
// System.out.println("Enter a URL : ");
|
|
||||||
// String urlInput = input.nextLine().trim();
|
|
||||||
// crawler(urlInput);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void crawler(String startUrl) {
|
|
||||||
// ArrayList<String> pending = new ArrayList<>();
|
|
||||||
// ArrayList<String> traversed = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// pending.add(startUrl);
|
|
||||||
// while (!pending.isEmpty() && traversed.size() <= 100) {
|
|
||||||
// String tempUrl = pending.remove(0);
|
|
||||||
// if (!traversed.contains(tempUrl)) {
|
|
||||||
// traversed.add(tempUrl);
|
|
||||||
// System.out.println("crawling: " + tempUrl);
|
|
||||||
//
|
|
||||||
// for (String s : getSubURLs(tempUrl)) {
|
|
||||||
// if (!traversed.contains(s)) pending.add(s);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static ArrayList<String> getSubURLs(String urlString) {
|
|
||||||
// ArrayList<String> subUrls = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// URL url = new URL(urlString);
|
|
||||||
// Scanner urlScanner = new Scanner(url.openStream());
|
|
||||||
// int cur = 0;
|
|
||||||
// while (urlScanner.hasNext()) {
|
|
||||||
// String input = urlScanner.nextLine();
|
|
||||||
// cur = input.indexOf("http:", cur);
|
|
||||||
// while (cur > 0) {
|
|
||||||
// int endIndex = input.indexOf("\"", cur);
|
|
||||||
// cur = endIndex > 0 ? input.indexOf("http:", endIndex) : -1;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return subUrls;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user