PHP script to show google ranking results

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

does anyone know if it is possible to display google page rank of a particular website using php script?

if it is possible, how do i do it?

profilepic.png
manpreet 2 years ago

 

Okay, i re-wrote my Answer and extracted only the relevant part of my SEO Helper (my previous version had other stuff like Alexa Rank, Google Index, Yahoo Links etc in it. If you are looking for that, just see check an older revision of this answer!)

Please be aware that there are pages that have NO PAGERANK and by no I DON'T MEAN ZERO. There is just none. This may be because the page is so very unimportant (even less im portant than PR 0) or just so new but might very well be important. This is consiedered the same as PR 0 in my class!

This has some pros and some cons. If possible you should handle it seperately in your logic, but this is not always possible, so 0 is the next best approach.

Furthermore:

This code is reverse engeneered and does not utilize some sort of API that has any form of SLA or whatever. So it might stop working ANY TIME!

And PLEASE DONT FLOOD GOOGLE!

I made the test. If you have only a very short period of sleep, google blocks you after 1000 requests (for quite some time!). With a random sleep between 1.5 and 2 secs it looks fine.

I once crawled the pagerank for 70k pages. Only once, because I just needed it. I did only 5k a day from several IPs and now i have the data and It doesnt get outdated because the pages are there for decades.

IMO its totally OK to check a pagerank once in a while or even some at once, but dont miss-use this code or google may lock us out all together!

php
/*
 * @author Joe Hopfgartner 
 */
class Helper_Seo
{

    protected function _pageRankStrToNum($Str,$Check,$Magic) {
        $Int32Unit=4294967296;
        // 2^32
        $length=strlen($Str);
        for($i=0;$i<$length;$i++) {
            $Check*=$Magic;
            //If the float is beyond the boundaries of integer (usually +/- 2.15e+9 = 2^31),
            // the result of converting to integer is undefined
            if($Check>=$Int32Unit) {
                $Check=($Check-$Int32Unit*(int)($Check/$Int32Unit));
                //if the check less than -2^31
                $Check=($Check<-2147483648)?($Check+$Int32Unit):$Check;
            }
            $Check+=ord($Str {
                $i
            });
        }
        return $Check;
    }
    /* 
    * Genearate a hash for a url
    */
    protected function _pageRankHashURL($String) {
        $Check1=self::_pageRankStrToNum($String,0x1505,0x21);
        $Check2=self::_pageRankStrToNum($String,0,0x1003F);
        $Check1>>=2;
        $Check1=(($Check1>>4)&0x3FFFFC0)|($Check1&0x3F);
        $Check1=(($Check1>>4)&0x3FFC00)|($Check1&0x3FF);
        $Check1=(($Check1>>4)&0x3C000)|($Check1&0x3FFF);
        $T1=(((($Check1&0x3C0)<<4)|($Check1&0x3C))<<2)|($Check2&0xF0F);
        $T2=(((($Check1&0xFFFFC000)<<4)|($Check1&0x3C00))<<0xA)|($Check2&0xF0F0000);
        return($T1|$T2);
    }
    /* 
    * genearate a checksum for the hash string
    */
    protected function CheckHash($Hashnum) {
        $CheckByte
                                                    
                                                    
0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.