I've written some code that retrieves from a search engine the number of websites that match a certain keyphrase. Eg -
function LoadPage($KeyPhrase)
{
$URLPath = "http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=%22$KeyPhrase%22";
$Handle = fopen($URLPath, "rb");
$Contents = "";
do
{
$Data = fread($Handle, 8192);
if (strlen($Data) == 0)
{
break;
}
$Contents .= $Data;
} while (true);
fclose($Handle);
return $Contents;
}
$KeyPhrase = str_replace(" ","+",$KeyPhrase);
$Content = LoadPage($KeyPhrase);
if (preg_match('/of about (.*?) for/',$Content,$matchesarray))
echo $matchesarray[1];
Would it be possible to amend this code to work out the SE ranking of a URL for that keyphrase? Or is there another way to do it? Any tips would be appreciated :-)