I'm trying to use Go and Chromedp to scrape some information from some websites. I'm currently using:
err := chromedp.Run(ctx, chromedp.Navigate(url), chromedp.Evaluate(`document.body.innerHTML`, &textHTML))
to pull the website text and parse it. I've run into an issue regarding URL redirects and I need to know the final URL in the chain to check it against a list of URLs. I could double pull it using net/http
and CheckRedirect
but that seems ridiculously inefficient. Is there a way I can add an Action
to Chromedp to get the redirect chain, or at least the final redirect URL? I was looking at NavigationEntries
but I don't see examples of it and I'm not sure if that's used for keeping track of Navigate
actions.
EDIT: I would still like to know if there's a solution that utilizes Chromedp internals, but I have worked around the problem by adding chromedp.Evaluate(`window.location.href`, &newURL)
to the Actions. Is there a case where this would not give me the desired result?