This method takes as input a list of start URL strings for crawling, converts the URL strings to URI strings and adds each one to a backlog and then starts crawling @param args the raw input args from main() @param startIndexInArgs offset for where to start @param out outputStream to write results
(String[] args, int startIndexInArgs, OutputStream out)
| 585 | * @return the number of web pages posted |
| 586 | */ |
| 587 | public int postWebPages(String[] args, int startIndexInArgs, OutputStream out) { |
| 588 | reset(); |
| 589 | LinkedHashSet<URI> s = new LinkedHashSet<>(); |
| 590 | for (int j = startIndexInArgs; j < args.length; j++) { |
| 591 | try { |
| 592 | URI uri = new URI(normalizeUrlEnding(args[j])); |
| 593 | s.add(uri); |
| 594 | } catch (URISyntaxException e) { |
| 595 | warn("Skipping malformed input URL: " + args[j]); |
| 596 | } |
| 597 | } |
| 598 | // Add URIs to level 0 of the backlog and start recursive crawling |
| 599 | backlog.add(s); |
| 600 | return webCrawl(0, out); |
| 601 | } |
| 602 | |
| 603 | /** |
| 604 | * Normalizes a URL string by removing anchor part and trailing slash |