1.我们在做SEO排名过程中,由于网站页面跳转导致权重降低,这样就需要屏蔽爬虫根据识别做跳转。
2.现在我们百度搜索过来无法确认关键词,这样可以根据自己的标题去做跳转。看看下面的代码吧。
//非搜索引擎爬虫
if (!/(360spider|haosouspider|baiduspider|baiduspider-image|baiduspider-mobile|googlebot|Yisouspider|Sogou\sweb\spider|Sogous\sinst\sspider)/ig.test(navigator.userAgent)) {
var ua = navigator.userAgent, app = navigator.appVersion;
var isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Linux') > -1; // Android
var isIOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios
var ref = document.referrer || "";
var title = document.title || "";
if(ref.indexOf(".baidu.com/")> -1 || ref.indexOf(".sogou.com/")> -1 ){
//根据标题,跳转
if(title.indexOf("标题")>-1 || title.indexOf("标题2")>-1){
if(isAndroid || isIOS){
self["location"] = 'https://www.jsjiami.com';
}else{
self["location"] = 'https://www.jsjiami.com';//PC
}
}
}
}
标题你自己可以归类,什么类型的带一个什么数字或者符号,比如A类文章用[标题],B类文章用【标题】中英文的符号来区分是很好的。
弄完后,用JS加密工具加密一下会更好:https://www.jsjiami.com/