문제

In my site, whenever there is a visit I send a cookie and then I save datas in db (data, ip, referer, platform). The cookie is used for avoid of recording the same user visit. My question is simple: how can I identify visit from robot? Is it possible?

도움이 되었습니까?

해결책

read User Agent

if( preg_match('/robot|spider|crawler|curl|^$/i', $_SERVER['HTTP_USER_AGENT'])) )
{ 
    echo 'Is bot or spider or crawler or curl or not human';
}
else
{
    echo 'Is human';
}

You can find a list of about 300 common user-agents given by bots here: http://www.robotstxt.org/db.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top