Created
January 8, 2015 16:26
-
-
Save damirazo/09beb8972adfaf8cd9b2 to your computer and use it in GitHub Desktop.
Получение контента страницы с указанным url в go
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
func getPage(link string) string { | |
response, err := http.Get(link) | |
if err != nil { | |
println("Произошла ошибка при загрузке страницы: " + link) | |
return "" | |
} | |
body, err := ioutil.ReadAll(response.Body) | |
if err != nil { | |
println("Произошла ошибка при попытке чтения контента страницы: " + link) | |
return "" | |
} | |
defer response.Body.Close() | |
return string(body) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment