Hi, I'd like to maka an array containing result from google query f.e; For query Digitalpoint : http://www.google.com/search?hl=en&...hts=&as_occt=any&cr=&as_nlo=&as_nhi=&safe=off I'd like to get all URL result in one array... does google API provide sth like this, or if there is a function or a class doing these, please respond, Regards, Cooker
This is how I used to do it before Google AJAX'ified their search results pages: <?php $keyword = 'php'; $search_results = file_get_contents('http://www.google.co.uk/search?hl=en&gl=uk&q='.$keyword.'&btnG=Search&meta='); $pattern = '#<h3 class=r><a href="(.*?)"[^>]*>(.*?)<\/a>.*?<div class="s">(.*?)<br>#'; // did we get any results? if (preg_match_all($pattern, $search_results, $links)) { for ($i=0; $i < count($links[1]); $i++) { $results[$i]['url'] = $links[1][$i]; $results[$i]['title'] = $links[2][$i]; $results[$i]['descr'] = $links[3][$i]; echo $results[$i]['url'] . "<br />\n" . $results[$i]['title'] . "<br />\n" . $results[$i]['descr'] . "<br /><br />\n\n"; } } ?> PHP: I'm afraid I haven't bothered to fix it since though - might be of use to you. The HTML that the Ajax loads into the DOM is almost identical to the one before, so the regex should still work when you figure out how to grab the HTML .