本文介绍了PHP:区分人类用户和机器人/其他的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 PHP 区分真实的人和机器人.我目前跟踪页面浏览量,由于机器人抓取我的页面,它们被大量夸大,所以我只想记录真实的人.如果它不是 100% 准确并不重要,我只是想要一种通过 PHP 实现的简单方法.

I want to, using PHP, differentiate between an actual person and a bot. I currently track page views and they are massively inflated due to bots crawling my pages so I want to only record real people. It doesn't matter if its not 100% accurate I just want a nice simple way to do it via PHP.

需要明确的是,这不是为了分析本身;这样我就可以跟踪每天提供的图像,以便我可以生成当天的热门图像"之类的脚本.

To be clear, this is not for analytics's per se; it is so that I can track what images are being served daily so I can produce a "top images of the day" sort of script.

推荐答案

您应该检查用户代理字符串,大多数表现良好的搜索机器人都会这样报告自己.

You should be checking the user agent string, most well behaved search bots will report themselves as such.

Google 的蜘蛛.

这篇关于PHP:区分人类用户和机器人/其他的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:53
查看更多