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

推荐订阅源

T
Tailwind CSS Blog
P
Proofpoint News Feed
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
Vercel News
Vercel News
Hugging Face - Blog
Hugging Face - Blog
GbyAI
GbyAI
博客园 - 聂微东
D
DataBreaches.Net
酷 壳 – CoolShell
酷 壳 – CoolShell
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
美团技术团队
H
Help Net Security
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
U
Unit 42
博客园 - 叶小钗
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
MongoDB | Blog
MongoDB | Blog

博客园 - 亲,注意身体

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;