Created
September 6, 2015 11:49
-
-
Save blackdev1l/f7e311232d7d35e9fd64 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
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