1236. Web Crawler
You are given a start URL startUrl, a list of all page URLs urls, and a directed edge list edges. Each edge [i, j] means that the page at urls[i] links to the page at urls[j], which is exactly what an HtmlParser.getUrls call on urls[i] would return.
Implement a web crawler that starts at startUrl, repeatedly discovers links from the pages it visits, and returns every URL that is reachable from startUrl under the same hostname as startUrl. You may return the answer in any order.
The crawler must:
- Start from the page
startUrl. - Follow outgoing edges exactly as
HtmlParser.getUrlswould return them. - Never crawl the same link twice.
- Explore only links whose hostname equals the hostname of
startUrl.
The hostname is the text after http:// and before the first /. Trailing slashes are significant: http://news.yahoo.com and http://news.yahoo.com/ are different URLs and are crawled independently.
1236. Web Crawler
You are given a start URL `startUrl`, a list of all page URLs `urls`, and a directed edge list `edges`. Each edge `[i, j]` means that the page at `urls[i]` links to the page at `urls[j]`, which is exactly what an `HtmlParser.getUrls` call on `urls[i]` would return.