php写的关于静态页面的蜘蛛爬行记录的代码

php中文网
发布: 2016-07-25 09:02:54
原创
1134人浏览过
  1. $useragent = addslashes(strtolower($_server['http_user_agent']));

  2. if (strpos($useragent, 'googlebot')!== false){$bot = 'google';}
  3. elseif (strpos($useragent,'mediapartners-google') !== false){$bot = 'google adsense';}
  4. elseif (strpos($useragent,'baiduspider') !== false){$bot = 'baidu';}
  5. elseif (strpos($useragent,'sogou spider') !== false){$bot = 'sogou';}
  6. elseif (strpos($useragent,'sogou web') !== false){$bot = 'sogou web';}
  7. elseif (strpos($useragent,'sosospider') !== false){$bot = 'soso';}
  8. elseif (strpos($useragent,'yahoo') !== false){$bot = 'yahoo';}
  9. elseif (strpos($useragent,'msn') !== false){$bot = 'msn';}
  10. elseif (strpos($useragent,'msnbot') !== false){$bot = 'msnbot';}
  11. elseif (strpos($useragent,'sohu') !== false){$bot = 'sohu';}
  12. elseif (strpos($useragent,'yodaobot') !== false){$bot = 'yodao';}
  13. elseif (strpos($useragent,'twiceler') !== false){$bot = 'twiceler';}
  14. elseif (strpos($useragent,'ia_archiver') !== false){$bot = 'alexa_';}
  15. elseif (strpos($useragent,'iaarchiver') !== false){$bot = 'alexa';}
  16. elseif (strpos($useragent,'slurp') !== false){$bot = '雅虎';}
  17. elseif (strpos($useragent,'bot') !== false){$bot = '其它蜘蛛';}
  18. if(isset($bot)){
  19. $fp = @fopen('bot.txt','a');
  20. fwrite($fp,date('y-m-d h:i:s')."\t".$_server["remote_addr"]."\t".$bot."\t".'http://'.$_server['server_name'].$_server["http_x_rewrite_url"]."\r\n");
  21. fclose($fp);
  22. }
  23. $file=".".$_server[http_x_rewrite_url];
  24. $f_head=substr($file,-5);
  25. if($f_head==".html")
  26. {
  27. if(file_exists($file))
  28. {
  29. echo file_get_contents($file);
  30. }else
  31. {
  32. header('http/1.1 404 not found');
  33. header("status: 404 not found");
  34. echo "该页面无法找到";

  35. }
  36. }
  37. else
  38. {
  39. header('HTTP/1.1 404 Not Found');
  40. header("status: 404 Not Found");
  41. echo "该页面无法找到";
  42. }
  43. ?>
复制代码

伪静态文件内容:

  1. [ISAPI_Rewrite]

    代码小浣熊
    代码小浣熊

    代码小浣熊是基于商汤大语言模型的软件智能研发助手,覆盖软件需求分析、架构设计、代码编写、软件测试等环节

    代码小浣熊 51
    查看详情 代码小浣熊
  2. # 3600 = 1 hour

  3. CacheClockRate 3600
  4. RepeatLimit 32
  5. # Protect httpd.ini and httpd.parse.errors files
  6. # from accessing through HTTP
  7. RewriteRule /index.html /index.php
  8. RewriteRule ^/article/(.*) /bot.php [L]
  9. RewriteRule ^/list/(.*) /bot.php [L]
复制代码


PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号