| AND OR | string words | *

forms

|

google results

| see demonstration of google results


this little snippet will extract the URLs of google results.
no - not only from the results - it's actually a full search form.



full source of google results [ line 1 - 39 ] | download google results

1    <?php
2   // lixlpixel google search
3   // rips the google result page apart and extracts the results
4   echo '<html>
5   <head>
6        <title>lixlpixel google search</title>
7   </head>
8   <body>';
9   if(!isset($_POST['q']))
10   {
11        echo '
12        <form action="'.$_SERVER['PHP_SELF'].'" method="post">
13             <input type="text" name="q">
14             <input type="submit" value="search">
15        </form>
16   ';
17   }else{
18         // this would be the URL if you want the results on page 2, 3 ... where $_POST['p'] is multiple of 10
19         // $off_site = 'http://www.google.com/search?q='.urlencode($_POST['q']).'&start='.$_POST['p']; 
20        $off_site 'http://www.google.com/search?q='.urlencode($_POST['q']).'&ie=UTF-8&oe=UTF-8'
21        $fp fopen ($off_site'r') or die('Unable to open file '.$off_site.' for reading'); 
22        while (!feof ($fp)) 
23        { 
24           $buf trim(fgets($fp4096)); 
25           $pos strpos($buf,'<p class=g>');
26           if($pos !== false)
27           {
28               $parts explode('<p class=g>',$buf);
29               $parts2 explode('http://',$parts[1]);
30               $parts3 explode('>',$parts2[1]);
31               echo '
32         <a href="http://'.$parts3[0].'" target="_blank">'.$parts3[0].'</a><br>'
33             } 
34         }
35   }
36   echo '
37   </body>
38   </html>';
39   ?>



32 hits by 14 users in the last 30 minutes.