27 lines
496 B
Go
27 lines
496 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
resp, err := http.Get("https://www.aemet.es/xml/municipios/localidad_46250.xml")
|
|
if err != nil {
|
|
log.Fatalf("Error occurred pulling data: %v\n", err)
|
|
}
|
|
defer resp.Body.Close()
|
|
if resp.StatusCode != http.StatusOK {
|
|
log.Fatalf("Error occurred accessing website: %v\n", err)
|
|
}
|
|
|
|
data, err := io.ReadAll(resp.Body)
|
|
if err != nil {
|
|
log.Fatalf("Error occurred reading data: %v\n", err)
|
|
}
|
|
|
|
fmt.Print(string(data))
|
|
}
|