Code written by php about the crawler record of static pages

Source: Internet
Author: User
Code written by php about the crawler record of static pages

  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, 'baidider Ider ')! = 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 = 'sososo ';}
  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 = 'Yahoo ';}
  17. Elseif (strpos ($ useragent, 'bot ')! = False) {$ bot = 'other Spider ';}
  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 "this page cannot be found ";

  35. }
  36. }
  37. Else
  38. {
  39. Header ('http/1.1 404 Not Found ');
  40. Header ("status: 404 Not Found ");
  41. Echo "this page cannot be found ";
  42. }
  43. ?>

Pseudo static file content:

  1. [ISAPI_Rewrite]

  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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.