如何用php识别机器人? [英] How to recognize bots with php?

查看:212
本文介绍了如何用php识别机器人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的用户建立统计信息,但不希望将机器人的访问次数计算在内.

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

现在我有一个基本的php,每次调用该页面时mysql都会增加1.

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

但是机器人也被添加到计数中.

But bots are also added to the count.

有人能想办法吗?

主要只是使事情变得混乱的主要因素. Google,Yahoo,Msn等

Mainly is just the major ones that mess things up. Google, Yahoo, Msn, etc.

推荐答案

您应按用户代理字符串进行过滤.您可以在此处找到由漫游器提供的大约300个常见用户代理的列表: http://www.robotstxt. org/db.html 运行该列表并忽略bot用户代理,然后再运行SQL语句应该可以解决所有实际问题.

You should filter by user-agent strings. You can find a list of about 300 common user-agents given by bots here: http://www.robotstxt.org/db.html Running through that list and ignoring bot user-agents before you run your SQL statement should solve your problem for all practical purposes.

如果您不希望搜索引擎访问该页面,请使用基本的 robots.txt 文件以阻止它们.

If you don't want the search engines to even reach the page, use a basic robots.txt file to block them.

这篇关于如何用php识别机器人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆