问题
Here's a code below which sends an email whenver any page is crawled by google and its resulting in spamming of mailbox. so is it possible to just record last crawled timestamp in a text file on server, which i can read later anytime using perl LWP mod. file should have just this data: 29,jan 2012 GMT etc If bot is visiting my site multiple times then it should overwrite txt file and record the last visit time only, 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 it by checking if google bot is hitting the server and what time it requested any page of site from server?
回答1:
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Googlebot' ) !== false ) {
file_put_contents('somefile.txt', 'Googlebot was here - ' . date(DATE_RFC822));
}
- http://php.net/manual/en/function.file-put-contents.php
- http://www.php.net/manual/en/function.date.php
来源:https://stackoverflow.com/questions/9048531/is-it-possible-to-find-when-google-bot-is-crawling-any-urls-on-my-site-and-recor