I'm trying to scrape the team names, dates and gametimes from this page:
http://sports.yahoo.com/nfl/scoreboard
My intent was not any kind of copyright infringement; I simply wanted to collect all the info and put it into database for use with a game I'm working on.
But I'm having problems gathering the day/date from the pages.
Using a preg_match function I found on (this) site, I've gotten the page separated into a large array.
And I've gotten the teams, records, and gametimes into arrays as hoped by using the following:
if (substr($page_array[$i],0,19)=="<a href=\"/nfl/teams")
{
$team[$t][0]=$page_array[$i+1]; // team name
$team[$t][1]=$page_array[$i+4]; // record
$team[$t][4]=$page_array[$i+8]; // game time
$team[$t][2]=$page_array[$i+25]; // opponent
$team[$t][3]=$page_array[$i+28]; // opponent record
if (is_odd($t)){
echo '<div><span><b>'.$team[$t][0].'</b> <small>'.$team[$t][1].'</small></span></div>';
echo "\r\n";
echo '<div><span> at <b>'.$team[$t][2].'</b> <small>'.$team[$t][3].'</small> <i>'.$team[$t][4].'</i></span></div>';
echo "\r\n";
}
$t++;
}
}
That works great. So I tried to load the day/date using a similar process, but it doesn't seem to be working:
if (substr($page_array[$i],1)==" <td colspan=\"3\" height=\"18\" class=\"yspdetailttl\"> \;")
{
$day[$d]=$page_array[$i+1]; //day and date of game
echo '<div>Date: '.$day[$d].'</div>';
echo "\r\n";
$d++;
}
The string is only used prior to the "Sunday October 8, 2006" and "Monday October 9, 2006", so it should only select those two data points.
I've tried using if ($page_array[$i]== but that didn't work either.
Ironically, the amount of time I've spent on learning this is longer than if I'd just typed all the data in manually.
Any help is appreciated.