I have a personal C# project that keeps track of live sports data during an event. It does this by scraping a JSON file on the sport's website. The JSON file is continuously updated during the sports event.
However, the page does NOT refresh itself. The existing file is simply overwritten. To monitor the data in real time as desired, I have to send requests continously for 2-4 hours -- from the start of the event, to the end.
My code is configured to loop endlessly until I hit the Esc key:
string url = "https://www.example.com/live/feeds/stats.json";
while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
{
try
{
string json = (new WebClient()).DownloadString(url);
// parse JSON
...
}
catch (...)
{
...
}
}
My questions are:
- If I do send such a high volume of requests for hours at a time, am I at risk of having my IP address blacklisted and access denied?
- Is it possible to monitor this JSON file continuously without sending a million requests?
- Can this be done using another language/framework? It doesn't need to be in C#.