Navigation

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • TeamSpeak

    Google Search API auslesen

    PHP
    1
    2
    1260
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Vinlow
      Vinlow last edited by

      Hier präsentiere ich einen Code mit dem man eine Google Suche starten und ihren Inhalt auslesen kann.

      ~PHP-Code:~

      [code]<?php

      $search = "MyTechZone Facebook"; //Suchtext
      $search = str_replace(' ', "%20", $search); //Leerzeichen entfernt
      $jsrc = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=".$search."&hl=de"; //Suche definiert
      $json = file_get_contents($jsrc);
      $jset = json_decode($json, true);

      echo "GSearch: ".utf8_decode($jset["responseData"]["results"][0]["GsearchResultClass"]);
      echo "
      ";
      echo "GSearch: ".utf8_decode($jset["responseData"]["results"][0]["unescapedUrl"]);
      echo "
      ";
      echo "Url: ".utf8_decode($jset["responseData"]["results"][0]["url"]);
      echo "
      ";
      echo "Sichtbare Url: ".utf8_decode($jset["responseData"]["results"][0]["visibleUrl"]);
      echo "
      ";
      echo "Url des Google Caches: ".utf8_decode($jset["responseData"]["results"][0]["cacheUrl"]);
      echo "
      ";
      echo "Title: ".utf8_decode($jset["responseData"]["results"][0]["title"]);
      echo "
      ";
      echo "Title unformatiert: ".utf8_decode($jset["responseData"]["results"][0]["titleNoFormatting"]);
      echo "
      ";
      echo "Inhalt: ".utf8_decode($jset["responseData"]["results"][0]["content"]);

      ?>[/code]

      ~Ausgabe:~
      [code]GSearch: GwebSearch
      GSearch: http://www.facebook.com/mytechzonede
      Url: http://www.facebook.com/mytechzonede
      Sichtbare Url: www.facebook.com
      Url des Google Caches: http://www.google.com/search?q=cache:tgmDWxoWTXQJ:www.facebook.com
      Title: MyTechZone.de | Facebook
      Title unformatiert: MyTechZone.de | Facebook
      Inhalt: MyTechZone.de is on Facebook. To connect with MyTechZone.de, sign up for Facebook today. Sign UpLog In · Cover Photo · Like · Create a Page · Privacy ...[/code]

      Bei Fragen oder Kommentaren schreibt bitte eine Antwort in das Thema.

      “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live”

      1 Reply Last reply Reply Quote 0
      • Vinlow
        Vinlow last edited by

        Hier präsentiere ich einen Code mit dem man eine Google Suche starten und ihren Inhalt auslesen kann.

        ~PHP-Code:~

        [code]<?php

        $search = "MyTechZone Facebook"; //Suchtext
        $search = str_replace(' ', "%20", $search); //Leerzeichen entfernt
        $jsrc = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=".$search."&hl=de"; //Suche definiert
        $json = file_get_contents($jsrc);
        $jset = json_decode($json, true);

        echo "GSearch: ".utf8_decode($jset["responseData"]["results"][0]["GsearchResultClass"]);
        echo "
        ";
        echo "GSearch: ".utf8_decode($jset["responseData"]["results"][0]["unescapedUrl"]);
        echo "
        ";
        echo "Url: ".utf8_decode($jset["responseData"]["results"][0]["url"]);
        echo "
        ";
        echo "Sichtbare Url: ".utf8_decode($jset["responseData"]["results"][0]["visibleUrl"]);
        echo "
        ";
        echo "Url des Google Caches: ".utf8_decode($jset["responseData"]["results"][0]["cacheUrl"]);
        echo "
        ";
        echo "Title: ".utf8_decode($jset["responseData"]["results"][0]["title"]);
        echo "
        ";
        echo "Title unformatiert: ".utf8_decode($jset["responseData"]["results"][0]["titleNoFormatting"]);
        echo "
        ";
        echo "Inhalt: ".utf8_decode($jset["responseData"]["results"][0]["content"]);

        ?>[/code]

        ~Ausgabe:~
        [code]GSearch: GwebSearch
        GSearch: http://www.facebook.com/mytechzonede
        Url: http://www.facebook.com/mytechzonede
        Sichtbare Url: www.facebook.com
        Url des Google Caches: http://www.google.com/search?q=cache:tgmDWxoWTXQJ:www.facebook.com
        Title: MyTechZone.de | Facebook
        Title unformatiert: MyTechZone.de | Facebook
        Inhalt: MyTechZone.de is on Facebook. To connect with MyTechZone.de, sign up for Facebook today. Sign UpLog In · Cover Photo · Like · Create a Page · Privacy ...[/code]

        Bei Fragen oder Kommentaren schreibt bitte eine Antwort in das Thema.

        “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live”

        1 Reply Last reply Reply Quote 0
        • First post
          Last post