Created
June 8, 2023 17:10
-
-
Save kahunacohen/e60efb6b0ceead0766bbebe276902b48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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