Created
April 2, 2015 08:24
-
-
Save iamveritas/25ebadedd69d3fd5bf9e to your computer and use it in GitHub Desktop.
letsrevolutionizetesting.com challenge
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
using System; | |
using System.Net; | |
namespace letsrevolutionizetesting | |
{ | |
class Challange | |
{ | |
// very quick and dirty solution to solve the letsrevolutionizetesting.com challenge | |
static void Main(string[] args) | |
{ | |
string follow = "http://letsrevolutionizetesting.com/challenge?id=461736456"; | |
while (true) | |
{ | |
string url2Follow = follow + "&format=json"; | |
Console.WriteLine("following: {0}", url2Follow); | |
// get url = follow&format=json | |
string content = string.Empty; | |
using (WebClient client = new WebClient()) | |
{ | |
content = client.DownloadString(url2Follow); | |
} | |
// extract follow, if not present break while loop | |
if (content.Contains("follow")) | |
{ | |
int startidx = content.IndexOf("\":\"", StringComparison.InvariantCultureIgnoreCase); | |
int length = content.Length - (startidx+1) - "\":\"".Length - 1; // startidx is zero based | |
follow = content.Substring(startidx + "\":\"".Length, length); | |
} | |
else | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment