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

查看:43
本文介绍了如何使用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.

有人能想出办法吗?

主要是把事情搞砸的主要因素.谷歌、雅虎、MSN 等

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

推荐答案

您应该按用户代理字符串进行过滤.您可以在此处找到机器人提供的大约 300 个常见用户代理的列表:http://www.robotstxt.org/db.html 在运行 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天全站免登陆