I try to use https://github.com/gocolly/colly.
I try to visit a URL and save the full response on my local disc for example visit google.com and save the full response body of the URL google.html.
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="bn"><head><meta content="text/html; charset=UTF-8" http-;google.pmc=JSON.parse(pmc);})();</script> </body></html>
func main() {
response, err := http.Get("https://www.google.com")
if err != nil {
log.Fatal(err)
}
defer response.Body.Close()
outFile, err := os.Create("google.html")
if err != nil {
log.Fatal(err)
}
defer outFile.Close()
// Copy data from HTTP response to file
_, err = io.Copy(outFile, response.Body)
if err != nil {
log.Fatal(err)
}
}
My expected output:
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="bn"><head><meta content="text/html; charset=UTF-8" http-;google.pmc=JSON.parse(pmc);})();</script> </body></html>
Aucun commentaire:
Enregistrer un commentaire