Here is the code below that sends an email when any page is crawled by Google, and this leads to spam in the mailbox. so that you can simply write the last timestamp in a text file on the server, which I can read later at any time using the Perl LWP mod. the file should have only this data: 29, jan 2012 GMT, etc. If the bot visits my site several times, it should overwrite the txt file and record only the time of the last visit, please help with some implementation, if possible
<?php if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Googlebot' ) !== false ) { // paste your email address here $my_email = ' your_email_address@email.com '; // notify via email mail($my_email,'[Notification]Googlebot Visit', 'Googlebot has just visited your website WEBSITE_NAME: '.$_SERVER['REQUEST_URI']); } ?>
I think we can do this by checking if the Google bot hit the server and at what time did it request any page of the site from the server?
source share