<?php
/*
* Projectname: GoogleIt
* Version: 1.2
* Author: Umang Beri <hide@address.com>
* Last modified: December 12, 2003
*
* Description:
* This class gets the latest headline from Google based on the topic
* you love
*/
class GoogleIt {
function GoogleIt($ID)
{
$pattern = "/ /i";
$replacement = "+" ;
$ID = preg_replace($pattern, $replacement, $ID);
return $this->ID = $ID;
}//end GoogleIt
function GoogleD($num = 1)
{
$str = "http://news.google.com/news?hl=en&edition=us&q=".$this->ID."&btnG=Search+News";
$handle = fopen($str, "rb");
while(!feof($handle))
{
$img = $img.fread($handle, 1024);
}//end while
fclose($handle);
$start = "<div>";
$end = "<p>";
$numL = ++$num;
for ($i=0; $i<$numL; $i++)
{
preg_match("/$start(.*?$end){0,$i}/s", $img, $str); //go through the page
$string = $string.preg_replace("/<br>/", " ", $str[1]);
$string = preg_replace("/<b>/", " ", $string);
$string = $string."\n";
}
return $string;
}
}//end class
?>