心理咨询网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SpiderController.php 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * @copyright (C)2016-2099 Hnaoyun Inc.
  4. * @license This is not a freeware, use is subject to license terms
  5. * @author XingMeng
  6. * @email hnxsh@foxmail.com
  7. * @date 2021年10月27日
  8. *
  9. */
  10. namespace app\home\controller;
  11. use core\basic\Controller;
  12. class SpiderController extends Controller
  13. {
  14. private $url;
  15. public function __construct($url = null)
  16. {
  17. $this->url = $url ? escape_string($url) : get('url');
  18. }
  19. public function index()
  20. {
  21. $rs = $this->getSpider();
  22. if ($rs !== false) {
  23. $this->log($rs . '爬行' . $this->url);
  24. }
  25. }
  26. private function getSpider()
  27. {
  28. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  29. if (strpos($useragent, 'googlebot') !== false) {
  30. return 'Google';
  31. } elseif (strpos($useragent, 'baiduspider') !== false) {
  32. return 'Baidu';
  33. } elseif (strpos($useragent, 'webscan') !== false) {
  34. return '360WebScan';
  35. } elseif (strpos($useragent, '360spider') !== false) {
  36. return '360So';
  37. } elseif (strpos($useragent, 'adsbot') !== false) {
  38. return 'Adwords';
  39. } elseif (strpos($useragent, 'bingbot') !== false) {
  40. return 'Bing';
  41. } elseif (strpos($useragent, 'slurp') !== false) {
  42. return 'Yahoo';
  43. } elseif (strpos($useragent, 'sosospider') !== false) {
  44. return 'Soso';
  45. } elseif (strpos($useragent, 'sogou') !== false) {
  46. return 'Sogou';
  47. } elseif (strpos($useragent, 'yodaobot') !== false) {
  48. return 'Yodao';
  49. } elseif (strpos($useragent, 'speedy') !== false) {
  50. return 'Speedy';
  51. } elseif (strpos($useragent, 'yandexbot') !== false) {
  52. return 'Yandex';
  53. } elseif (strpos($useragent, 'easouspider') !== false) {
  54. return 'Easou';
  55. } elseif (strpos($useragent, 'symantecspider') !== false) {
  56. return 'Symantec';
  57. } elseif (strpos($useragent, 'qiniu') !== false) {
  58. return 'Qiniu';
  59. } elseif (strpos($useragent, 'jiankongbao') !== false) {
  60. return 'JianKongBao';
  61. } elseif (strpos($useragent, 'dnspod') !== false) {
  62. return 'DNSPod';
  63. } elseif (strpos($useragent, 'linkpadbot') !== false) {
  64. return 'Linkpad';
  65. } elseif (strpos($useragent, 'mj12bot') !== false) {
  66. return 'MJ12';
  67. } elseif (strpos($useragent, 'dingtalkbot') !== false) {
  68. return 'DingTalk';
  69. } elseif (strpos($useragent, 'bytespider') !== false) {
  70. return 'Byte';
  71. } elseif (strpos($useragent, 'zoominfobot') !== false) {
  72. return 'Zoominfo';
  73. } elseif (strpos($useragent, 'yisouspider') !== false) {
  74. return 'Yisou';
  75. } elseif (strpos($useragent, 'spider') !== false) {
  76. return 'other-spider';
  77. } elseif (strpos($useragent, 'bot') !== false) {
  78. return 'other-bot';
  79. }
  80. return false;
  81. }
  82. }