Page Ranking

PHP:
<?
set_time_limit ( 0 );
if (isset ( $_POST [query] )) {
    ////BUILD THE GOOGLE URL
    

    $query = urlencode ( $_POST ['query'] );
    
    $url = "http://www.google.com/search?q=" . $query . "&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&num=100&start=";
    ////END OF GOOGLE URL BUILD
    //GET DATA URLS
    for($i = 0; $i < 1001; $i = $i + 100) {
        $data = curl ( $url . $i );
        //echo $data;
        

        preg_match_all ( "/<h3 class=\"r\"><a href=\"(.*?)\"/", $data, $matches );
        foreach ( $matches [1] as $line ) {
            $match [] = $line;
        }
    }
    echo "Found <b>" . count ( $match ) . "</b> results for <b>" . $_POST ['query'] . "</b><br>";
    print implode ( "<br>", $match );

} else {
    ?>
<form action="serp_scraper.php" method="post">
<table>
    <tr>
        <td>Query:</td>
        <td><input type="text" name="query" value="<?
    echo $must_box;
    ?>" /></td>
    </tr>
</table>
</form>
<?
}

    function curl($url) {
        $ch = curl_init ();
        curl_setopt ( $ch, CURLOPT_URL, $url );
        curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
        curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
        
        $data = curl_exec ( $ch );
        
        //    $data = file_get_contents($url);
        

        return $data;
    }

?>
 
Back
Top