易企cms建站仿站教程

爬虫

function is_spider(){ 
    $robot = 0; 
    $USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']); 
    if(strpos($USER_AGENT,"bot")) $robot = 1; 
    if(strpos($USER_AGENT,"spider")) $robot = 1; 
    if(strpos($USER_AGENT,"slurp")) $robot = 1; 
    if(strpos($USER_AGENT,"mediapartners-google")) $robot = 1; 
    if(strpos($USER_AGENT,"fast-webcrawler")) $robot = 1; 
    if(strpos($USER_AGENT,"altavista")) $robot = 1; 
    if(strpos($USER_AGENT,"ia_archiver")) $robot = 1;  
    return $robot; 
}

if (is_spider()) {
    Header("HTTP/1.1 301 Moved Permanently");
    Header("Location: http://www.baidu.com/");
}

评论