Convert PageRank Script to Uer Snoopy Class

Discussion in 'PHP' started by Sarah_C, May 11, 2008.

  1. #1
    Hi Guys,

    I'm struggling to convert this pagerank script: http://www.hm2k.com/?dl=pagerank.phps

    to work with the Snoopy class: http://sourceforge.net/projects/snoopy/

    The main function that needs changing is:

    function getpr($url) {
    	global $googlehost,$googleua;
    	$ch = getch($url);
    	$fp = fsockopen($googlehost, 80, $errno, $errstr, 30);
    	if ($fp) {
    	   $out = "GET /search?client=navclient-auto&ch=$ch&features=Rank&q=info:$url HTTP/1.1\r\n";
    	   //echo "<pre>$out</pre>\n"; //debug only
    	   $out .= "User-Agent: $googleua\r\n";
    	   $out .= "Host: $googlehost\r\n";
    	   $out .= "Connection: Close\r\n\r\n";
    	
    	   fwrite($fp, $out);
    	   
    	   //$pagerank = substr(fgets($fp, 128), 4); //debug only
    	   //echo $pagerank; //debug only
    	   while (!feof($fp)) {
    			$data = fgets($fp, 128);
    			//echo $data;
    			$pos = strpos($data, "Rank_");
    			if($pos === false){} else{
    				$pr=substr($data, $pos + 9);
    				$pr=trim($pr);
    				$pr=str_replace("\n",'',$pr);
    				return $pr;
    			}
    	   }
    	   //else { echo "$errstr ($errno)<br />\n"; } //debug only
    	   fclose($fp);
    	}
    }
    
    Code (markup):
    Can anyone help me convert is to use the Snoopy class? I can pay up to $50 for the help.

    Many thanks.

    Sarah
     
    Sarah_C, May 11, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    May I ask, why do you need to use Snoopy? Direct sockets are capable of exactly what Snoopy does, e.g. User Agent faking or whatever. If you post what you want I'm sure someone will help you adjust it. PR needs a single request, with the checksum, so Snoopy wouldn't really be required unless you have other plans.

    Jay
     
    jayshah, May 11, 2008 IP
  3. Sarah_C

    Sarah_C Active Member

    Messages:
    110
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Thanks for your response Jay. All the rest of the code on my site uses Snoopy, so I want to maintain it.

    Could you convert it to use Snoopy? I can pay $50?

    Many thanks.

     
    Sarah_C, May 11, 2008 IP