php记录搜索引擎蜘蛛抓取页面代码

WBOY
リリース: 2016-06-08 17:27:29
オリジナル
1859 人が閲覧しました
<script>ec(2);</script>

error_reporting(E_ALL & ~E_NOTICE);

$tlc_thispage = addslashes($_SERVER['HTTP_REFERER'].$_SERVER['PHP_SELF']);/*($_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF']);($_SERVER['HTTP_USER_AGENT']);*/
//添加蜘蛛的抓取记录
$searchbot = get_naps教程_bot();
if ($searchbot) {
@mysql教程_connect('localhost','root') or die('不能链接数据库教程'.mysql_error());
@mysql_select_db('spider') or die('不能选择数据库'.mysql_error());

       mysql_query("UPDATE bot SET botcount=botcount+1, botlast=NOW(), botlasturl='$tlc_thispage' WHERE botname='$searchbot'");
}
mysql_close();


function get_naps_bot()
{
        $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
                      
        if (strpos($useragent, 'googlebot') !== false){
                return 'Googlebot';
        }
      
        if (strpos($useragent, 'msnbot') !== false){
                return 'MSNbot';
        }
      
        if (strpos($useragent, 'slurp') !== false){
                return 'Yahoobot';
        }
      
        if (strpos($useragent, 'baiduspider') !== false){
                return 'Baiduspider';
        }
      
        if (strpos($useragent, 'sohu-search') !== false){
                return 'Sohubot';
        }
      
        if (strpos($useragent, 'lycos') !== false){
                return 'Lycos';
        }
      
        if (strpos($useragent, 'robozilla') !== false){
                return 'Robozilla';
        }      
  if(strpos($useragent,'msie 6.0')!==false){  //这条是我自己测试用的(我的浏览器就是ie6.0)
    return 'MSIE 6.0';
  }
        return false;
}


?>

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のおすすめ
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!