How to recognize bots with php?

后端 未结 7 772
囚心锁ツ
囚心锁ツ 2020-12-24 14:33

I am building stats for my users and dont wish the visits from bots to be counted.

Now I have a basic php with mysql increasing 1 each time the page is called.

相关标签:
7条回答
  • 2020-12-24 15:20

    You can check the User Agent string, empty strings, or strings containing 'robot', 'spider', 'crawler', 'curl' are likely to be robots.

    preg_match('/robot|spider|crawler|curl|^$/i', $_SERVER['HTTP_USER_AGENT']));

    0 讨论(0)
提交回复
热议问题