惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园 - 【当耐特】
量子位
Engineering at Meta
Engineering at Meta
博客园_首页
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
V
Visual Studio Blog
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
Jina AI
Jina AI
The Cloudflare Blog
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
博客园 - 聂微东

博客园 - 亲,注意身体

magento 数据清理 magento top menu edit CookieConter 转换为string magento sitemap cms page remove home and generate sitemap error magento toplink blank li magento 语言包 magetno awblog auto generate title id, js replace magento moneybooker 操作 JS 正则 js 数组 组合(转) magento checkout require moneybooker api/mqi query magento moneybooker redirect 添加信任站点 bat 设置信任站点等级 moneybooker api 文档 magento htaccess Navicat 注册码,序列号 magento 修改订单号 Magento 删除所有订单 适于于1.4+
magento 记录蜘蛛爬行日志
亲,注意身体 · 2012-03-17 · via 博客园 - 亲,注意身体

<?php  
 function isSpider(){
    $bots = array(
                    'google'    => 'googlebot',
                    'yahoo'        => 'yahoo slurp',
                    'soso'        => 'sosospider',
                    'msn'        => 'msnbot',
                    'altavista'    => 'scooter',
                    'sogou'        => 'sogou spider',
                    'bing'        => 'bing',
                    'yodao'        => 'yodaobot',
                    
                    
            );
    $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
    foreach ($bots as $k => $v){
    
        if (strstr($userAgent,$k)){
            return $v;
            break;
        }
    }
    return false;
}
$spi= isSpider();
if($spi){
    $tlc_thispage    = addslashes($_SERVER['HTTP_USER_AGENT']);
    //$file            = 'r.txt';
    $time            = date('Y-m-d H:i:s',mktime());
    //$handle            = fopen($file,'a+');
    $PR                = $_SERVER['REQUEST_URI'];
mysql_connect("localhost","root","");//连接MySQL
mysql_select_db("db");//选择数据库
$sql = "insert into robots(website,robot,url,agent,time) values ('website','$spi','$PR','$tlc_thispage','$time')";
mysql_query($sql);//借SQL语句插入数据
mysql_close();//关闭MySQL连接
 //echo  "Time:{$time} ROBOT:{$spi} AGENT:{$tlc_thispage} URL:{$PR} \n\r";
   // fwrite($handle, "Time:{$time} ROBOT:{$spi} AGENT:{$tlc_thispage} URL:{$PR} \n\r");
    //fclose($handle);
}
?>

CREATE TABLE `robots` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `website` varchar(20) NOT NULL,
  `url` varchar(300) NOT NULL,
  `robot` varchar(20) NOT NULL,
  `time` datetime DEFAULT NULL,
  `agent` varchar(50) DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;