How can I detect a crawler / spider using PHP?
I am currently working on a project where I need to monitor every visit to the crawler.
I know that you should use HTTP_USER_AGENT, but I'm not sure how to format the code for this purpose, and I know that the CUSTOM agent can be changed very simply, so I would also like to know if a few more options can be added to avoid spoofing ?
Sample code of what I'm trying to do.
<?php $user_agent = $_SERVER['HTTP_USER_AGENT']; if (strpos( $user_agent, 'Google') !== false) { echo "Googlebot is here"; } ?>
thanks
source share