Programmatically determine Page Rank from a PHP script?

by tomcam
3 replies
Is there a way to programmatically determine Page Rank from a PHP script?

thanks--

TC
#determine #google pr #page #page rank #pagerank #php #programmatically #rank #script
  • Profile picture of the author Mkj
    Not sure I follow you but there are freebee code snippets that display page rank. Do a google search for 'prchecker' and use the top result. They supply some code that you can add to display a website page rank.
    {{ DiscussionBoard.errors[3704962].message }}
  • Profile picture of the author kaido
    Here you go

    PHP Code:
    function get_pr()
    {
         = -
    1;
        
         = 
    curl_init();
        
    curl_setopt(, CURLOPT_URL'http://www.google.com/search?client=navclient-auto&ch='.CheckHash(hashURL()).'&features=Rank&q=info:'..'&num=100&filter=0');
        
    curl_setopt(, CURLOPT_TIMEOUT60);
        
    curl_setopt(, CURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4 GTB6 (.NET CLR 3.5.30729)"); 
        
    curl_setopt(, CURLOPT_SSL_VERIFYHOSTfalse);
        
    curl_setopt(, CURLOPT_SSL_VERIFYPEERfalse);
        
    curl_setopt(, CURLOPT_HEADERfalse);
        
    curl_setopt(, CURLOPT_FOLLOWLOCATIONtrue);
        
    curl_setopt(, CURLOPT_RETURNTRANSFERtrue);
        
         = 
    curl_exec();
         = array(
    '/ss+/','/v/');
         = 
    preg_replace(, ' ', );
        
        if()
        {
             = 
    strpos(, "Rank_");
            if( === 
    false)
            {
                 = 
    "N/A";
            }
            else
            {
                 = 
    substr(,  + 9);
            }
            if( == 
    "-1")
            {
                 = 
    "N/A";
            }
            return ;
        }
        else
        {
             = 
    "N/A";
            return ;
        }
    }

    function 
    strToNum(, , ) 
    {
         = 
    4294967296;
         = 
    strlen();
        for ( = 
    0;  < ; ++)
        {
             *= ;
            if ( >= )
            {
                 = ( -  * (int) ( / ));
                 = ( < -
    2147483648)? ( + ) : ;
            }
             += 
    ord();
        }
        return ;
    }

    function 
    hashURL() 
    {
         = 
    strToNum(, 0x15050x21);
         = 
    strToNum(, 00x1003F);

         >>= 
    2;
         = (( >> 
    4) & 0x3FFFFC0 ) | ( & 0x3F);
         = (( >> 
    4) & 0x3FFC00 ) | ( & 0x3FF);
         = (( >> 
    4) & 0x3C000 ) | ( & 0x3FFF);

         = (((( & 
    0x3C0) << 4) | ( & 0x3C)) <<) | ( & 0xF0F );
         = (((( & 
    0xFFFFC000) << 4) | ( & 0x3C00)) << 0xA) | ( & 0xF0F0000 );

        return ( | );
    }

    function 
    checkHash()
    {
         = 
    0;
         = 
    0;

         = 
    sprintf('%u', ) ;
         = 
    strlen();

        for( =  - 
    1;  >= 0;  --)
        {
             = ;
            if (
    === ( % 2))
            {
                 += ;
                 = (int)( / 
    10) + ( % 10);
            }
             += ;
             ++;
        }

         %= 
    10;
        if(
    0!== )
        {
             = 
    10 - ;
            if (
    === ( % 2) )
            {
                if (
    === ( % 2))
                {
                     += 
    9;
                }
                 >>= 
    1;
            }
        }
        return 
    '7'..;

    Call as get_pr("YOURURLHERE");
    Signature

    {{ DiscussionBoard.errors[3720609].message }}
    • Profile picture of the author tomcam
      Doh! Of course! Thank you, kaido!
      {{ DiscussionBoard.errors[3722320].message }}

Trending Topics