View Full Version : Extracting Season Schedules for League Website
RedDoby
07-22-2014, 11:47 PM
How are multi-player leagues extracting the team schedules for their website? There are not any schedule data files for unplayed games that I can find. Are they read from the league html created by FOF7? That is the only way I can think of getting team schedule information.
gstelmack
07-23-2014, 06:46 AM
Future games are actually an issue right now. Results are exported, but not future games.
RedDoby
07-23-2014, 12:35 PM
I am going to see if I can write some code to read the league html generated by FOF7.
RedDoby
07-25-2014, 01:11 AM
I was able to get this to work. If anyone wants the code let me know. The code pulls the opponent team id and whether or not it is a home or away game.
aston217
07-25-2014, 01:51 AM
Would love for you to post the code. Wish it were included in the Export Data, but Jim appears set on that.
Dutch
07-25-2014, 04:50 AM
I was able to get this to work. If anyone wants the code let me know. The code pulls the opponent team id and whether or not it is a home or away game.
The RNFL would like to check it out!
Would love for you to post the code. Wish it were included in the Export Data, but Jim appears set on that.
It would be nice to have, that's for sure.
RedDoby
07-25-2014, 10:03 AM
This looks up the schedule for a specific team by teamID number. You have to upload the league html files from the game to your server in order for this to work. Note this hasn't fully been tested, once games are complete the html changes, but I think it should still work then. If not I can fix it. Here is the code below.
//Get schedule from FOF7 HTML schedule file and insert into array
// this creates a two dimensional numerically indexed array named $schedule , $schedule[1] is preseason week 1 and $schedule[22] is regular season week 17, following the same week numbers as FOF7
// each week has 3 indexes, index 0 can be ignored, index 1 is the team number of the opponent for that week or is NULL if on a bye, and index 2 let's you know whether it is a home game (1 for TRUE) or away (0 for FALSE)
//$teamID is the team ID of the team you are looking up the schedule for, you will need to supply that variable
$teamID=
//for the first part of the $URL below insert the location where you save the league html on your server
$URL = "http://www.YOURWEBSITE/HTMLLOCATION/ " . $teamID . "schedule.html";
//$lastSeason is used to search file and stop once we reach the part where it starts the schedule of the previous season
//I have done so by looking up the curyear in fof7_gameinfo and subtracting one, replace $laststage->curyear-1 with the year of your most recent season or your own variable
$lastSeason = $laststage->curyear-1 . " Exhibition Season";
$file = fopen($URL, "r") or die("Unable to open file!");
$n=1;
while ($line = fgets($file)) {
//$lastSeason is used to search file and stop once we reach the part where it starts the schedule of the previous season
if(stristr($line,$lastSeason)) {
break;
}
elseif(stristr($line,"Week")) {
preg_match("/\"([0-9]+)/", $line, $schedule[$n]);
IF (stristr($line,"at ")) {
$schedule[$n][2]=0;//False if away game
}
ELSE {
$schedule[$n][2]=1;//True if not an away game
}
$n++;
}
}
fclose($file);
Dutch
07-26-2014, 05:48 AM
Cool! So I'm imagining running the HTML once at the beginning of a season, then running this code...and then somehow dumping it into a SQL table. I'd have to look into how to do that though. Never tried it. :)
RedDoby
07-26-2014, 09:04 AM
This code is more designed for including on your team pages to display their schedules. For example, on our website I look up the team information of the opponent using the $schedule array by looping through the array and displaying that information in a html table. If you wanted to use this to insert data into a new database table, then write some code and add this to an admin page of your site and include the code to insert it when that page is loaded or a button is clicked. That is much more advanced though then just looking up the info each time the page is loaded.
Dutch
07-26-2014, 09:48 AM
Ok. I will play with it tonight or tomorrow.
Dutch
09-06-2014, 10:12 AM
Well, I've been unsuccessful in getting this to work. My PHP skills truly suck.
I did however do a simple scrape of the schedule with Excel, normalize it into a csv file and then import it into MySQL with my import scripts. Kind of a pain in the ass, but not really a big deal.
Still though, in the 'Export Data' function, it would be so awesome for this csv to be included and populated each season.
team_schedule ('year', 'week', 'home_team_id','visitor_team_id').
This would give us the ability to put previews on the web-sites without having to load the HTML, scrape the html, update the database, build relationships to week's with different naming conventions ('export data' and 'htmlfiles' have slightly different naming conventions for stage names.)
Anyway, just trying to help make 'import data' more better. :)
RedDoby
09-11-2014, 09:30 AM
Shame man this is what I was able to get to display on our league's site. Wish I could help. The NFLsim » Team_Schedule (http://www.s487856674.onlinehome.us/NFLsim/team/schedule/?id=25)
Dutch
09-11-2014, 12:28 PM
That looks great! I will at least have the full schedule worked out for next season, but I was hoping for something a little easier to implement. The one thing I have learned the most since getting into this endeavor of FOF web-site development is that you will learn new and exciting ways to accomplish simple stuff. I feel a lot smarter at least. :)
RedDoby
09-11-2014, 04:35 PM
That is absolutely correct. ;) It is a hobby worth pursuing, especially with everything going web based.
vBulletin v3.6.0, Copyright ©2000-2026, Jelsoft Enterprises Ltd.