Polling Websites and Reading Web Page
This lesson gives insight into how to check the status of a website with Go and how to read a page on the web.
We'll cover the following...
We'll cover the following...
Introduction
Sending a website a very simple request and seeing how the website responds is known as polling a website.
Explanation
Consider the following example where a request includes only an HTTP header.
In the program above, we import the package net/http (see line 4). All URLs in an array of strings urls (defined at line 7) are polled. At line 16, we start an iteration over urls with a for-range loop. At line 17, a simple http.Head() request is sent to each url to see how they react. The function’s signature is: func Head(url string) (r *Response, err error). When there is ...