31) { die("Search string too long."); } // lets not be too cruel, stop them at 100 results if($amount > 100) { $amount = 100; } // create our search URL, first the server in http:// $url = 'http://www.google.com/'; // now start the query with the amount $url .= 'search?num='.$amount.'&'; // now lets add the search string (url-encoded) $url .= 'q=%22'.urlencode($string).'%22&'; // and finally google's identifier $url .= 'btnG=Search'; // echo it for testing echo $url."




"; // use our get_url function to grab the content $content = $this->get_url($url); /* make sure we reformat it (14/05), trademark liabilities */ // and now lets echo the content we just scraped return $content; } function parse_results($results) { $opener = "
returnSubStrings($results, $opener, $closer); // $doneres should be reformatted into a decent array now with some ereg stuff // currently the content is just as a "blob" return $doneres; } } /* sample code START */ // create a new instantiation of the google class $google = new google; // use the results function to get our content (this will just echo out the contents of the array) $results = $google->results("gcse", 5); //echo $results."




"; $parsed = $google->parse_results($results); print_r($parsed)."




"; foreach($parsed as $parse) { if(stristr("bard id=gbardd", $parse)) { $parse = returnSubStrings($parse, "
"); } echo $parse; } /* sample code END */ ?>