我的问题是我有很多人。在这个数组中是浏览器(过去用来访问我的网站的用户),还有机器人和蜘蛛。
它看起来像这样:Mozilla,Mozilla,Mozillabot,Mozilla,Unicornbot等。
我需要获取阵列中的每个键,其中包含“ bot”,例如mozillabot,unicornbot。
但是我找不到东西。
array_search
也行不通array_keys
。
有人知道Laravel提供的解决方案吗?
您可以使用“爬网程序检测”库,这使识别机器人/爬网程序/蜘蛛非常容易。它可以像几行代码一样简单。以下是摘自图书馆文档的摘录:
use Jaybizzle\CrawlerDetect\CrawlerDetect;
$CrawlerDetect = new CrawlerDetect;
// Check the user agent of the current 'visitor'
if($CrawlerDetect->isCrawler()) {
// true if crawler user agent detected
}
// Pass a user agent as a string
if($CrawlerDetect->isCrawler('Mozilla/5.0 (compatible; Sosospider/2.0; +http://help.soso.com/webspider.htm)')) {
// true if crawler user agent detected
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句