So I have a php page that I use to grab NFL scores for a family football pool that I run.
I previously used to web scrap an ESPN website but they changed their format and I sought an easier approach. I finally ended up finding a nice little xml file provided by nfl.com that is very minimal and contains all of the information I need.
Example url:
http://www.nfl.com/ajax/scorestrip?season=2015&seasonType=REG&week=15
This xml file gets updated in near real time and is perfect, except for one minor problem that I'm running into and that's the fact that I keep getting cached results. The ONLY way that I have been able to get around this is by setting up a cron job to use wget to download the file every X amount of minutes and have my php parse the downloaded file.
Things I have tried that DO NOT work:
1) Adding a dummy variable to the URL I am trying to scrape from to have a "unique" url. Example:
http://www.nfl.com/ajax/scorestrip?season=2015&seasonType=REG&week=15&dummy=1923751975
2) Using php to call exec which runs a wget command (same command that I setup in the cron job). For some reason, this still gets the cached result.
3) All sorts of php header variables to try to prevent caching.
Here's a code snippet of my stuff:
Any suggestions would be appreciated.
I previously used to web scrap an ESPN website but they changed their format and I sought an easier approach. I finally ended up finding a nice little xml file provided by nfl.com that is very minimal and contains all of the information I need.
Example url:
http://www.nfl.com/ajax/scorestrip?season=2015&seasonType=REG&week=15
This xml file gets updated in near real time and is perfect, except for one minor problem that I'm running into and that's the fact that I keep getting cached results. The ONLY way that I have been able to get around this is by setting up a cron job to use wget to download the file every X amount of minutes and have my php parse the downloaded file.
Things I have tried that DO NOT work:
1) Adding a dummy variable to the URL I am trying to scrape from to have a "unique" url. Example:
http://www.nfl.com/ajax/scorestrip?season=2015&seasonType=REG&week=15&dummy=1923751975
2) Using php to call exec which runs a wget command (same command that I setup in the cron job). For some reason, this still gets the cached result.
3) All sorts of php header variables to try to prevent caching.
Here's a code snippet of my stuff:
Code:
<?php
header("Content-type: text/xml");
header("Cache-Control: max-age=0, no-cache, no-store, must-revalidate");
header("Pragma: no-cache");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: Sat, 26 Jul 1997 05:00:00 GMT");
$url = "http://www.nfl.com/ajax/scorestrip?season=".
$year."&seasonType=REG&week=".$week."&dummy=".time();
$xml = simplexml_load_file($url);
Any suggestions would be appreciated.