Created
February 14, 2020 14:01
-
-
Save piEsposito/4bea3770caa60060414784ad4a3583ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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 query_handler | |
import ( | |
"compress/gzip" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"os" | |
) | |
func ConvertGzipToString(resp *http.Response) string { | |
/* | |
As our return from the request is compressed in gzip format, | |
We return it as a string to be written in a file | |
*/ | |
reader, _ := gzip.NewReader(resp.Body) | |
result, _ := ioutil.ReadAll(reader) | |
return string(result) | |
} | |
func SaveJsonString(content string, path string) { | |
/* | |
With this function we save our crawled Json to string | |
*/ | |
f, _ := os.Create(path) | |
fmt.Fprintln(f, content) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment