How to recognize bots with php?(如何使用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识别机器人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用php识别机器人?
基础教程推荐
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01