且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过JavaScript检测搜索爬虫

更新时间:2023-02-26 13:22:35

这是正则表达式ruby UA agent_orange 库用于测试 userAgent 看起来像是机器人。您可以通过在此处引用 bot userAgent列表来缩小特定机器人的范围。 :

This is the regex the ruby UA agent_orange library uses to test if a userAgent looks to be a bot. You can narrow it down for specific bots by referencing the bot userAgent list here:

/bot|googlebot|crawler|spider|robot|crawling/i

例如你有一些对象, util.browser ,你可以存储什么类型的设备用户开启:

For example you have some object, util.browser, you can store what type of device a user is on:

util.browser = {
   bot: /bot|googlebot|crawler|spider|robot|crawling/i.test(navigator.userAgent),
   mobile: ...,
   desktop: ...
}