Skip to content

Instantly share code, notes, and snippets.

@CyberRoute
Created October 5, 2018 10:27
Show Gist options
  • Save CyberRoute/0ae4b5fffd791cb58682c29b413afca1 to your computer and use it in GitHub Desktop.
Save CyberRoute/0ae4b5fffd791cb58682c29b413afca1 to your computer and use it in GitHub Desktop.
challenge_go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
response, err := http.Get("http://letsrevolutionizetesting.com/challenge.json")
if err != nil {
return
}
var f interface{}
for true {
json_resp, err := ioutil.ReadAll(response.Body)
err = json.Unmarshal(json_resp, &f)
if err != nil {
break
}
f2, ok := f.(map[string]interface{})
next_url, ok := f2["follow"].(string)
if !ok {
fmt.Println(f2["message"])
break
}
next_url = strings.Replace(next_url, "challenge", "challenge.json", 1)
fmt.Printf("%v\n", next_url)
response, err = http.Get(next_url)
if err != nil {
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment