Created
October 5, 2018 10:27
-
-
Save CyberRoute/0ae4b5fffd791cb58682c29b413afca1 to your computer and use it in GitHub Desktop.
challenge_go
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 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