PHP calls Gogle API implementation Google query

xiaoxiao2021-03-06  78

//demand:

//http://www.phpclass.org download a class file for Googlesearch.php

// get the name (http://dietrich.ganx4.com/nusoap)

// register with google to receive an authentication key. You can

// register online at http://www.google.com/apis/.

Require_once 'Googlesearch.php';

$ GS = New Googlesearch ();

$ GS-> SetKey ("vzpqepxqfhkyvghenuvejgvf ********"); // Fill in your own Google Key

$ GS-> setQueryString ("Battery"); // set query string to search.

$ GS-> SetStartResult (10);

$ GS-> SetMaxResults (10); // set max. Number of results to be returned.

$ GS-> setsafesearch (true); // set Google "SafeSearch" Feature.

$ search_result = $ gs-> dosearch ();

Echo "Document Filtering:" $ search_Result-> getDocumentfiltering (). "
";

Echo "Search Comments:". $ search_result-> getsearchcomments (). "
";

Echo "EstimatedTotalResultscount:" $ search_Result-> getstimatedTotalResultscount (). "
";

Echo "Is Estimate Exact:" $ search_result-> getstimateisexact (). "
";

Echo "Search Query:". $ search_result-> getsearchquery (). "
";

Echo "Start INDEX:" $ search_result-> getStartIndex (). "
";

Echo "End Index:" $ search_Result-> getndIndex (). "
";

Echo "Search Tips:" $ search_result-> getsearchtips (). "
";

Echo "Search Time:" $ search_result-> getsearchtime (). "
";

$ RE = $ search_result-> getresultElements ();

Foreach ($ RE $ ELEMENT)

{

ECHO "

";

Echo "
Title:" $ element-> gettitle ();

Echo "URL:". $ Element-> getURL ();

Echo "
Snippet:". $ element-> getSnipplet ();

Echo "
Summary:". $ element-> getsummary ();

Echo "
Host Name:". $ element-> gethostname ();

Echo "Related Information Present ?:" $ ELEMENT-> getReleaseDinformationPresent ();

Echo "Cached Size:". $ element-> getcachedsize ();

Echo "
Directory Title:" $ element-> getdirectoryTitle ();

$ DIRCAT = $ Element-> getdirectorycategory ();

Echo "
Full Viewable Name:" $ DIRCAT-> getFullViewAblename ();

Echo "Special Encoding:" $ DIRCAT-> getSpeciaalencoding ();

}

?>

转载请注明原文地址:https://www.9cbs.com/read-122109.html

New Post(0)