Skip to content

Instantly share code, notes, and snippets.

@blackdev1l
Created September 6, 2015 11:49
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 blackdev1l/f7e311232d7d35e9fd64 to your computer and use it in GitHub Desktop.
Save blackdev1l/f7e311232d7d35e9fd64 to your computer and use it in GitHub Desktop.
func (r *Runner) getJSON() {
thread := strconv.Itoa(r.thread)
jsonURL := "http://a.4cdn.org/" + r.board + "/thread/" + thread + ".json"
resp, err := http.Get(jsonURL)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var parsed map[string]interface{}
err = json.Unmarshal(body, &parsed)
if err != nil {
log.Fatal(err)
}
for _, value := range parsed {
posts := value.([]interface{})
for _, post := range posts {
parsed := post.(map[string]interface{})
if parsed["ext"] != nil {
fmt.Println(int(parsed["tim"].(float64)))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment