三叔用的判断是不是蜘蛛的代码

php 文章 2021-05-10 09:26 414 0 全屏看文

AI助手支持GPT4.0

function startWith($str, $needle) {
	return strpos($str, $needle) === 0;
}

function isRobotIP() {
  $ip=getip(); 
   // echo $agent= strtolower($_SERVER['HTTP_USER_AGENT']); 
    if (!empty($ip)) { 
        $spiderSite= array( 
          '123.125.',
   '220.181.',
   '121.14.',
   '203.208.',
   '210.72.',
   '125.90.',
   '218.0.',
   '216.239.',
   '64.233.',
   '66.102.',
   '66.249.',
   '72.14.',
   '202.101.',
   '222.73.',
   '66.249.65.',
   '101.226.',
   '180.153.',
   '182.118.',
   '61.55.',
   '101.',
   '123.126.',
   '218.30.',
   '61.135.',
   '42.156.',
   '42.120.',
   '202.106.',
   '202.108.',
   '222.185.',
   '65.54.',
   '207.46.',
   '207.68.',
   '219.133.',
   '202.96.',
   '202.104.',
   '219.142.',
   '66.196.',
   '68.142.',
   '72.30.',
   '74.6.',
   '202.165.',
   '202.160.',
        ); 
        foreach($spiderSite as $val) { 
            if (startWith($ip, $val)) {
                return true; 
            } 
        } 
    } else { 
        return false; 
    } 
}


做了个工具 查询是否是蜘蛛:

http://sanshu.cn/tools1/spiderquery/

image.png

-EOF-

AI助手支持GPT4.0