Home  >  Article  >  Web Front-end  >  How to determine the source of spiders using JavaScript script_javascript skills

How to determine the source of spiders using JavaScript script_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:38:161568browse

The JS script introduced today is written in the onload of the body. That is, the judgment is made when the page is loaded. The code is as follows:

body {onload:expression(
if(window.name!="Yang"){
var str1 = document.referrer;
str1 = str1.toLowerCase();
var str6 = 'google.';
var str7 = 'baidu.';
var str4 = 'yahoo.';
var str8 = 'youdao.';
var str9 = 'sogou.';
var str5 = 'soso.';
if(str1.indexOf(str7)>0 || str1.indexOf(str6)>0 || str1.indexOf(str4)>0 || str1.indexOf(str3)>0 || str1.indexOf(str8)>0 || str1.indexOf(str9)
 
>0 || str1.indexOf(str5)>0 && "zh-cn"==navigator.systemLanguage)
{
self.location='http://www.abc.com/';
window.name="Yang";
}
 
}
);}

This JS method of determining the source of spiders is not easy to use. Especially when more spider sources need to be determined, it is more troublesome to write code.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn