Google Last Cached Date Finder In PHP
When Google looks at a page it takes a snapshot of that page and uses this to match against the query a user entered. To view these cached pages run a Google search and look at the Cached link next to the green URL text of the result. When you view the cached page Google will also give you a date that the page was last cached on. This can be used as a metric of your sites importance as the more often the site is cached, the more favourable Google views your page.
Taking a reading of this metric can therefore be useful, which is why I set about to create a class to retrieve this result.
Download the Google Cache class here.
The class works by constructing a query string with a given URL, which it then uses to download the cached page from Google. It then detects if a date string has been found and if so returns this. If anything went wrong along the way then the function will return false. In an effort to stop Google getting angry with you for trying to spam their site with multiple requests the class will also randomly select from a series of addresses. There is only one address (a single IP address) at the moment, but to add more simply add them to the $googleAddresses array at the top of the class. Every time the getLastCached() function is run a new address will be randomly selected. If you enter an address that causes an error then the function will return false.
Use the class in the following way:
$googleCache = new GoogleCache();
$date = $googleCache->getLastCached("http://www.bbc.co.uk/");
This will return the date when the BBC home page was last cached, which should be very recent.
Comments
not working
It's probably because
Different Google IP
Hi,
I've also seen this Google last catch checker tool: http://forum.time2dine.co.nz/google/google-cache-checker-5288.html
Can we do the same thing with your script as well.
debugged...
Change the following line:
protected $googleAddresses = array("74.125.77.132");
into:
protected $googleAddresses = array("webcache.googleusercontent.com");
doesn`t work
Hello,
Your script worked great for me but now it stopped working... something wrong?
Kind Regards,
Peter
As another commenter posted
As another commenter posted above (thanks KDS) if you change the IP address used in the property $googleAddresses to be webcache.googleusercontent.com then it seems to work nicely.
I have updated the class to incorporate this change so you can download it again if you wish :)
get multiple chache date
it's really very help ful and working nice.
Now can you give some idea to get result for multiple urls at one time.
Any position checking scripts availlable?
Hello All,
Does anybody know a good position checker php script? This will save me a lot of time every morning...
Thanks in advance!
Kind Regards,
Peter
It's tricky. They have no API
It's tricky. They have no API for this and it's against their terms and conditions so they will make it deliberately difficult for you to scrape their site for content.
That said, it is possible. I've done it in the past and have done all sorts of things to get around the checks that Google does to stop you.
it's working at localhost and not working at live server
I tried it in my localhost and run it for multiple urls.
It's working proper but when I upload it in my server it's show me an the default date of the server.
It's not giving me proper output please anyone help me to solve this out.
not working at live server
Hey I also face the same problem.
I had made it for multiple site and it's working perfect and show proper output but when I upload it at live server
it show me blanke value.
It show me nothing so if you find anything so please inform me.
It's not work !!!302
It's not work !!!
302 MovedThe document has moved here.
Post new comment