The following C# code downloads the JSON of a Reddit random page. It is correctly downloading and looping if the value found is not valid. However, the returned string is the same for about a minute straight of checking. Does anybody know if this is a memory problem, a Reddit API problem, or a webClient problem?
string src = "";
while(src.endsWith(<someString>))
{
src = dl(<valid site>);
}
void dl(string st)
{
string json = new WebClient().DownloadString(string);
...
string src = <manipulation of json>;
...
return src;
}
If you're fetching the same reddit url, you are hitting the akamai cache. While you can bypass the akamai cache by visiting api.reddit.com
instead of www.reddit.com
, your program should respect reddit's API rules, which include, "don't hit the same page more than once per 30 seconds."