Mit folgendem kleinen Code kann man sich die Vorschläge und das Suchvolumen bei Google zu einem Keyword anzeigen lassen.
Am Ende gibt es wieder einen kurzen Beispiel Code, wie man das ganze verwenden könnte.
class base
{
function crawlUrl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204");
if (!($contents = trim(@curl_exec($ch)))) {
$this->debugRes("error","curl_exec failed");
}
curl_close ($ch);
return $contents;
}
}
class googlesuggest
{
function getSuggestions($keyword)
{
$content=base::crawlUrl("http://google.com/complete/search?output=toolbar&q=".urlencode($keyword));
$data=simplexml_load_string($content);
return((array) $data);
}
}
Beispiel Code zur Ausgabe:
$googlesuggest=new googlesuggest;
$data=$googlesuggest->getSuggestions("dsl flatrate");
foreach($data['CompleteSuggestion'] as $loop)
{
echo $loop->suggestion->attributes()->data ." - ".$loop->num_queries->attributes()->int."";
}
Related posts:

April 21st, 2010 on 14:58
ich bekomme des öfteren dabei die fehlermeldung:
Node no longer exists … on line 06
woran liegt das?
April 21st, 2010 on 15:00
Kannst du mir das Keyword nennen bei dem das Auftritt?
Gerne auch per Mail ( siehe Impressum )