Source Code for the CNN Grabber
| From: | Ron | Date: | Thu, 28 Mar 2002 15:36:32 +0000 |
| Subject: | Source Code for the CNN Grabber | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-90536@lists.php.net to get a copy of this message | ||
This is the source, which is to advanced for me to debug!!!
Waiting on their responce and maybe they can help me.....Anybody have any
clues
<?
#--------------------------------#
# spider_cnn.php
#
# Copyright W3matter.com LLC
# http://www.w3matter.com
#--------------------------------#
# Released under the GNU
# Please keep this copyright
# notice intact.
#--------------------------------#
#- Spider CNN for latest headlines
#- Fetch the page and remove newlines
$page = @join("",file("http://www.cnn.com/"));
$page = str_replace("\n","",$page);
#- Grab the latest news segment from the page
if(preg_match("/OTHER TOP NEWS(.*?)\/other news/",$page,$match))
{
#- Grep each headline and it's URL
if(preg_match_all('/<a
href="(.*?)">(.*?)<\/a>/',$match[1],$matches))
{
$out = "<h3>Today's CNN Headlines</h3>";
$out .= "<font size=-1>\n";
$out .= "<ul>\n";
$num = count($matches[1]);
for($x=0;$x<$num;$x++)
{
$url = "http://www.cnn.com".$matches[1][$x];
$title = $matches[2][$x];
$out .= "<li> <a href=$url target=blank>$title</a>\n";
}
$out .= "</ul>\n";
$out .= "</font>\n";
echo $out;
}
}
?>