PC(电脑端)抓取来源页面搜索内容及更改来源页面所搜内容:直奔主题
测试的时候还是IE浏览器是一大问题,因为IE会清空referrer,IE又得受到贵宾级待遇!
相比之下Firefox和Chrome都会保留referrer!
支持百度搜索,搜狗,好搜(其余自己照着添加)
function a(i, j) {
var k = "?wd=";
var l = "&wd=";
var m = "###";
var n = "&";
var o = i.indexOf(k);
if (o == -1) {
o = i.indexOf(l)
};
i = i.substring(o + 4, i.length);
var o = i.indexOf(m);
if (o == -1) {
o = i.indexOf(n)
};
if (o != -1) {
i = i.substring(0, o)
};
if (navigator.userAgent.indexOf("MSIE") != -1) {
window.opener.document.location = j
} else {
window.opener.location.href = j
}
};
function b(i, j) {
var k = "?query=";
var l = "&query=";
var m = "###";
var n = "&";
var o = i.indexOf(k);
if (o == -1) {
o = i.indexOf(l)
};
i = i.substring(o + 7, i.length);
var o = i.indexOf(m);
if (o == -1) {
o = i.indexOf(n)
};
if (o != -1) {
i = i.substring(0, o)
};
if (navigator.userAgent.indexOf("MSIE") != -1) {
window.opener.document.location = j + i
} else {
window.opener.location.href = j + i
}
};
function f(i, j) {
var k = "?q=";
var l = "&q=";
var m = "###";
var n = "&";
var o = i.indexOf(k);
if (o == -1) {
o = i.indexOf(l)
};
i = i.substring(o + 3, i.length);
var o = i.indexOf(m);
if (o == -1) {
o = i.indexOf(n)
};
if (o != -1) {
i = i.substring(0, o)
};
if (navigator.userAgent.indexOf("MSIE") != -1) {
window.opener.document.location = j + i
} else {
window.opener.location.href = j + i
}
};
var g = "http://www.baidu.com";
var h = document.referrer;
h = h.toLowerCase();
//我想要搜的内容->urlencode->%e6%88%91%e6%83%b3%e8%a6%81%e6%90%9c%e7%9a%84%e5%86%85%e5%ae%b9
if (h.indexOf("baidu.com/") != -1) {
g="https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=baidu&wd=%e6%88%91%e6%83%b3%e8%a6%81%e6%90%9c%e7%9a%84%e5%86%85%e5%ae%b9";
a(h, g)
}else if(h.indexOf("sogou.com/") != -1) {
g = "http://www.sogou.com/web?query=%e6%88%91%e6%83%b3%e8%a6%81%e6%90%9c%e7%9a%84%e5%86%85%e5%ae%b9";
b(h, g)
}else if(h.indexOf("haosou.com/")!= -1){
g = "https://www.haosou.com/s?ie=utf-8&shb=1&src=360sou_newhome&q=http://www.sogou.com/web?query=%e6%88%91%e6%83%b3%e8%a6%81%e6%90%9c%e7%9a%84%e5%86%85%e5%ae%b9";
c(h, g);
}
</script>
个浏览器版本navigator.userAgent 判断MISE为IE浏览器:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36
firefox
版本 45.0.1Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
遨游
版本 v4.4.8.2000Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Maxthon/4.4.8.2000 Chrome/30.0.1599.101 Safari/537.36
360
版本8.1.1.134 内核 45.0Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
IE11
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; rv:11.0) like GeckoIE6-9都有MISE
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 6.1; WOW64; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)顶一下,微笑~