Guest User

Untitled

a guest
Sep 5th, 2011
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <?php
  2. ini_set("memory_limit", "256M");
  3. set_time_limit(2400);
  4. include_once('simple_html_dom.php');
  5. include_once('inc/connect.php');
  6. //jan 31, feb 28, march 31, april 30, may 31, june 30, july 31, aug 31, sept 30, oct 31, nov 30, dec 31
  7. //for ($year = 2009; $year < 2010; $year++) {
  8. for ($Week = 1; $Week < 18; $Week++) {
  9. // season type 1 = pre season, 2 = rs, 3 = post season
  10. $url = "http://scores.espn.go.com/nfl/scoreboard?seasonYear=2011&seasonType=2&weekNumber=" . $Week;
  11. $dom = file_get_html($url);
  12. $bullpen = $dom->find('div[class=gameDay-Container]');
  13. for ($count = 0; $count < sizeof($bullpen); $count++) {
  14. $gamebox = $dom->find('div[class=gameDay-Container]', $count)->find('div[class=mod-content]');
  15. $date = explode(",", $dom->find('h4[class=games-date]', $count)->plaintext);
  16. $daymonth = explode(" ",trim($date[1]));
  17. $time = $daymonth[0] . " " . $daymonth[1] . " " . $date[2];
  18. $fdate = date("Y-m-d", strtotime($time));
  19. for ($count2 = 0; $count2 < sizeof($gamebox); $count2++) {
  20. $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);
  21. $dTime = date("H:i", strtotime(str_replace('ET', '', $cTime)));
  22. $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));
  23. $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));
  24. $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);
  25. //echo $gameID[1] . "," . $fdate . "," . $homeTeam[1] . "," . $visTeam[1] . "<BR>";
  26.  
  27. $PW = "RS";
  28. $sql = "INSERT INTO Games.NFLGames (`idNFL` , `startDate` , `startTime` ,`awayTeam` ,`homeTeam`,`Week` ,`Season`) VALUES ('$gameID[1]', '$fdate', '$dTime', '$visTeam[1]', '$homeTeam[1]', '$Week', '$PW');";
  29. echo $sql . "<BR>";
  30. $query = mysql_query($sql, $connection);
  31. }
  32. }
  33. $dom->clear();
  34. unset($dom);
  35. }
  36. //}
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment