Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Programmatically determine Page Rank from a PHP script? (https://www.warriorforum.com/programming/364515-programmatically-determine-page-rank-php-script.html)

tomcam 14th April 2011 08:13 AM

Programmatically determine Page Rank from a PHP script?
 
Is there a way to programmatically determine Page Rank from a PHP script?

thanks--

TC

Mkj 14th April 2011 08:26 AM

Re: Programmatically determine Page Rank from a PHP script?
 
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.

kaido 17th April 2011 02:35 AM

Re: Programmatically determine Page Rank from a PHP script?
 
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_TIMEOUT, 60);
    
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_VERIFYHOST, false);
    
curl_setopt(, CURLOPT_SSL_VERIFYPEER, false);
    
curl_setopt(, CURLOPT_HEADER, false);
    
curl_setopt(, CURLOPT_FOLLOWLOCATION, true);
    
curl_setopt(, CURLOPT_RETURNTRANSFER, true);
    
     = 
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(, 0x1505, 0x21);
     = 
strToNum(, 0, 0x1003F);

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

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

    return ( | );
}

function 
checkHash()
{
     = 
0;
     = 
0;

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

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

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

Call as get_pr("YOURURLHERE");

tomcam 17th April 2011 11:35 AM

Re: Programmatically determine Page Rank from a PHP script?
 
Doh! Of course! Thank you, kaido!


All times are GMT -6. The time now is 09:23 AM.