searchTerm))
{
$page = file_get_contents('http://www.google.com/search?hl=en&q='.urlencode($this->searchTerm).'&btnG=Google+Search&num=100');
preg_match_all('/href=\"(http\:\/\/[a-zA-Z0-9\-\_\/\.]+?)\"/',$page,$matches);
$this->urls = $matches[1];
}
else
{
echo("Search term not yet set!
\n");
}
}
function getBackLinks()
{
if(isset($this->urls))
{
foreach($this->urls as $url)
{
echo("Finding backlinks for $url
\n");
flush();
$p1 .= file_get_contents('http://www.google.com/search?hl=en&q=link:'.urlencode($url).'&btnG=Google+Search&num=100');
}
preg_match_all('/href=\"(http\:\/\/[a-zA-Z0-9\-\_\/\.]+?)\"/',$p1,$matches);
$fh = fopen($this->searchTerm.'.txt','a');
foreach($matches[1] as $m)
{
echo("Writing out $m
\n");
flush();
fwrite($fh,"$m\n");
}
fclose($fh);
}
else
{
echo("Not yet scraped!
\n");
}
}
}
?>