This is going to be the largest step so far, and will require the most "figuring it out on your own"... you got this.
func crawlPage(rawBaseURL, rawCurrentURL string, pages map[string]int)
rawCurrentURL is the current URL we're crawlingrawBaseURL is the root URL of the website we're crawlingIn the first call to crawlPage() rawCurrentURL is a copy of rawBaseURL, but as we make further HTTP requests to all the URLs we find on the rawBaseURL, the rawCurrentURL value will change while the base stays the same.
The pages map keeps track of the number of times we've seen each internal link. This function should continue to pass the same map to itself.
Here's my pseudocode:
rawCurrentURL is on the same domain as the rawBaseURL. If it's not, just return. We don't want to crawl the entire internet, just the domain in question.rawCurrentURL.pages map already has an entry for the normalized version of the current URL, just increment the count and be done, we've already crawled this page.pages map for the normalized version of the current URL, and set the count to 1.Be careful testing this! Be sure to add print statements so you can see what your crawler is doing, and kill it with ctrl+c if it's stuck in a loop. If you make too many spammy requests to a website (including my blog) you could get your IP address blocked.
go run . https://wagslane.dev
Login to Complete
Login to view solution