May
26
Plain Google Results in PHP
Filed Under (Code) by Mystalia on 26-05-2008
Tagged Under : google, php, results
function PlainResults($term)
{
$content = file_get_contents('http://www.google.com/search?num=100&safe=off&q=' . $term);
if ($content !== false)
{
$content = str_replace("http", "\nhttp", $content);
$content = str_replace("\"", "\n\"", $content);$line = explode(”\n“, $content);
$i = 0;while($line[$i] != “”)
{
$temp = trim($line[$i]);
if(substr($temp, 0, 21) !== “http://www.google.com” and substr($temp, 0, 1) !== “\”” and substr($temp, strlen($temp) – 1, 1) == “/“)
{
echo “$temp
\n“;
}
$i++;
}
}
This script will output googles directory results as just plain urls.