How can I use Golang's net/http's http.Get(url string)
but block certain url's and resources from request?
E.g.
http.Get("https://google.com") // But somehow block the main CSS file.
How can I use Golang's net/http's http.Get(url string)
but block certain url's and resources from request?
E.g.
http.Get("https://google.com") // But somehow block the main CSS file.
You do not need to block URLs and resources because net/http Get()
will not automatically perform fetching of included links or resources.
You probably confuse it with how a browser fetches a URL. A browser will issue a request and then follow up with fetching all the resources (Javascript/CSS/images/videos etc.) But Go's net/http request is much lower level - it is more like curl fetch - it will follow redirect by default, but otherwise it will just fetch a single response to the GET request. You can think of the result of issuing a call `http.Get("https://google.com") as similar to what you see as in the browser as the page source (plus HTTP headers and response code). This response will likely to include a number of other URLs for links and resources - if you like, you can parse them out and request some or all of them (leaving out what you would want to "block"), like low-level web crawlers do.