Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set("memory_limit", "256M");
- set_time_limit(2400);
- include_once('simple_html_dom.php');
- include_once('inc/connect.php');
- //jan 31, feb 28, march 31, april 30, may 31, june 30, july 31, aug 31, sept 30, oct 31, nov 30, dec 31
- //for ($year = 2009; $year < 2010; $year++) {
- for ($Week = 1; $Week < 18; $Week++) {
- // season type 1 = pre season, 2 = rs, 3 = post season
- $url = "http://scores.espn.go.com/nfl/scoreboard?seasonYear=2011&seasonType=2&weekNumber=" . $Week;
- $dom = file_get_html($url);
- $bullpen = $dom->find('div[class=gameDay-Container]');
- for ($count = 0; $count < sizeof($bullpen); $count++) {
- $gamebox = $dom->find('div[class=gameDay-Container]', $count)->find('div[class=mod-content]');
- $date = explode(",", $dom->find('h4[class=games-date]', $count)->plaintext);
- $daymonth = explode(" ",trim($date[1]));
- $time = $daymonth[0] . " " . $daymonth[1] . " " . $date[2];
- $fdate = date("Y-m-d", strtotime($time));
- for ($count2 = 0; $count2 < sizeof($gamebox); $count2++) {
- $cTime = trim($dom->find('div[class=gameDay-Container]', $count)->find('div[class=mod-content]', $count2)->find('div[class=game-header]', 0)->find('p', 0)->plaintext);
- $dTime = date("H:i", strtotime(str_replace('ET', '', $cTime)));
- $visTeam = explode("=", strtoupper($dom->find('div[class=gameDay-Container]', $count)->find('div[class=mod-content]', $count2)->find('p[class=team-name]', 0)->find('a', 0)->href));
- $homeTeam = explode("=", strtoupper($dom->find('div[class=gameDay-Container]', $count)->find('div[class=mod-content]', $count2)->find('p[class=team-name]', 1)->find('a', 0)->href));
- $gameID = explode("=", $dom->find('div[class=gameDay-Container]', $count)->find('div[class=mod-content]', $count2)->find('div[class=game-links]', 0)->find('a', 0)->href);
- //echo $gameID[1] . "," . $fdate . "," . $homeTeam[1] . "," . $visTeam[1] . "<BR>";
- $PW = "RS";
- $sql = "INSERT INTO Games.NFLGames (`idNFL` , `startDate` , `startTime` ,`awayTeam` ,`homeTeam`,`Week` ,`Season`) VALUES ('$gameID[1]', '$fdate', '$dTime', '$visTeam[1]', '$homeTeam[1]', '$Week', '$PW');";
- echo $sql . "<BR>";
- $query = mysql_query($sql, $connection);
- }
- }
- $dom->clear();
- unset($dom);
- }
- //}
- ?>
Advertisement
Add Comment
Please, Sign In to add comment