I have to check the google maps ranking of specific websites for given keywords.
I know how to do a normal google search and look through the results, but google maps is different and my code is not working.
I've been looking all over the internet for ideas and some code on how it should be done but I've got nothing so far.
Maybe somebody here has some knowledge about this. I'd greatly appreciate it.
Here is some code for an ordinary google search:
//...
if (isset($_GET['url']) && isset($_GET['keyword'])) {
$gg_url = 'http://www.google.com/search?hl=en&q=' . urlencode($_GET['keyword']) . '&start=';
$url = preg_replace('(^http://|/$)','',$_GET['url']);
for ($page = 0; $page < 9; $page++) {
$handle = fopen($gg_url . $page . 0 ,'r');
$scraped = '';
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
$scraped .= $buffer;
}
fclose($handle);
}
$results = array();
preg_match_all('/a href="([^"]+)" class=l.+?>.+?<\/a>/',$scraped,$results);
foreach ($results[1] as $serp) {
$serp = preg_replace('(^http://|/$)','',$serp);
if ($serp == $url) {
header('Location: ' . $gg_url. $page . '0');
exit;
}
}
}
$er = 'Not in top 100 search results';
}
//...