安装:

npm run fingerprintjs/botd

使用:可以建一个utils文件,

import { load } from '@fingerprintjs/botd'
// 判断是否脚本
export async function botDetect() {
  const botdPromise = load()
  botdPromise
    .then(botd => botd.detect())
    .then(result => {
      // 结果示例:{ bot: true, type: 'headless' } 或 { bot: false }
      console.log('检测结果:', result)
      return result.bot
    })
    .catch(error => console.error('检测失败:', error))
}

页面使用:

import { botDetect } from '@/utils/index.js'

// 非人操作上报
    async getCollet() {
      const isBot = await botDetect()
      if (isBot) {
        // 是爬虫则上报给接口
      }
    }
Logo

火山引擎开发者社区是火山引擎打造的AI技术生态平台,聚焦Agent与大模型开发,提供豆包系列模型(图像/视频/视觉)、智能分析与会话工具,并配套评测集、动手实验室及行业案例库。社区通过技术沙龙、挑战赛等活动促进开发者成长,新用户可领50万Tokens权益,助力构建智能应用。

更多推荐