- <?
- // Live Football Score Fetch
- // Get Live Score Information from ESPN Soccernet.
- // You'll need a frontend to this, such as an ajax frontend
- // or IRC bot.
- // Make a database connection
- // This function will remove the specified HTML tags out of a string.
- }
- }
- }
- // This function uses libcurl to fetch the contents of a page, its a
- // huge amount faster than php's own file_get_contents()
- function get_content($url) {
- $ch = curl_init();
- curl_setopt ($ch, CURLOPT_URL, $url);
- curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla 5.0");
- curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
- curl_exec ($ch);
- curl_close ($ch);
- }
- // Start of the regex to match
- $start = "<div id="OutputWindow" class="vidiText">";
- // End of the regex to match
- $end = "<div style="clear: both; padding: 0px 0; border-bottom: 1px solid #CCCCCC; width:748px;">";
- // The feed url to fetch
- $page = get_content($url);
- $scores = $match[1];
- $scores = strip_selected_tags($scores,"div");
- // Loop through the links collected and add them to the database.
- // Add each link to db
- // Lookup and see if its been added
- // Don't add it, its there already.
- // Add it to the database
- $i = mysql_query("INSERT INTO `scores` (`timestamp`,`status`,`text`) VALUES ('".time()."','1','".addslashes($final)."')");
- }
- }
- }
- }
- ?>
Code / PHP Snippets / ESPN Football Score Fetch
Download as Text : January 6th, 2009
This work is licensed under a