fingerprintjs/botd爬虫监听
安装:
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) {// 是爬虫则上报给接口}}