您所在的位置:首页 - PHP - 正文PHP

php判断来源是否是蜘蛛

萧何-Vincent 萧何-Vincent 2021-11-04 【PHP】 1137人已围观

/**
 * 判断是否是蜘蛛
 */
function fromRobot($except = '') {
   $ua = strtolower ( $_SERVER ['HTTP_USER_AGENT'] );
   $botchar = "/(baidu|google|spider|soso|yahoo|sohu-search|yodao|robozilla|AhrefsBot)/i";
   $except ? $botchar = str_replace ( $except . '|', '', $botchar ) : '';
   if (preg_match ( $botchar, $ua )) {
      return true;
   }
   return false;
}


Tags: PHP

文章评论 (暂无评论,1137人围观)

我的名片

网名:Vincent

职业:IT

现居:SZ

Email:53126692@qq.com

站长寄语:技术分享,支持原创!

站点信息

  • 文章总数:65
  • 页面总数:1
  • 分类总数:5
  • 标签总数:12
  • 评论总数:24
  • 浏览总数:82970
取消
微信二维码
支付宝二维码

目录[+]