Skip to content

Instantly share code, notes, and snippets.

@kahunacohen
Created June 8, 2023 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kahunacohen/e60efb6b0ceead0766bbebe276902b48 to your computer and use it in GitHub Desktop.
Save kahunacohen/e60efb6b0ceead0766bbebe276902b48 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
response, err := http.Get("https://example.com")
if err != nil {
fmt.Println("Error:", err)
return
}
defer response.Body.Close()
// Read the response body
htmlBytes, err := io.ReadAll(response.Body)
if err != nil {
fmt.Println("Error:", err)
return
}
// Convert bytes to string
html := string(htmlBytes)
// Print the HTML content
fmt.Println(html)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment