I'm trying to scrape some site using proxy that i get from free-proxy-list.net and apply it in my local http request using Golang, but when i parse the proxy using url.Parse() always return Invalid Control Character URL
func getProxy() *url.URL {
proxyUrl := "https://www.proxy-list.download/api/v1/get?type=http&country=US"
client := &http.Client{}
req, err := http.NewRequest("GET", proxyUrl, nil)
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error proxy ", err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error response body", err)
}
details := string(body)
temp := strings.Split(details, "
")
fmt.Println("http://" + temp[rand.Intn(30)])
checkProxy, err := url.Parse("http://" + temp[rand.Intn(10)])
if err != nil {
fmt.Println("Bad proxy URL", err)
}
return checkProxy
}