<%
';--------------------------------
';Baidu搜索小偷ASP完美版
';--------------------------------
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = ubb(strReturn)
End Function
Function dq(key)
dim XmlHttp
set XmlHttp = CreateObject("Microsoft.XMLHTTP")
XmlHttp.Open "GET","http://www.baidu.com/s?wd="&key&"&pn="&request("pn"), false
XmlHttp.setRequestHeader "Content-Type","text/XML"
XmlHttp.Send
dq = bytes2BSTR(XmlHttp.responseBody)
End Function
Function BR(Str)
Str = Replace(Str,"{br}"," ")
Str = Replace(Str,vbcrlf," ")
Str = Replace(Str,"
"," ")
Str = Replace(Str,"
"," ")
Str = Replace(Str,"
"," ")
BR = Str
End Function
function ubb(str)
if instr(str,"找到相关网页") = 0 then
ubb = "没有搜索到任何内容"
exit function
end if
str = Replace(str,vbcrlf,"{br}")
str = Replace(str," ","{br}")
str = Replace(str,"
","")
ubb = BR(UBB)
re.Pattern="(找到相关网页.*秒)"
Set Matches = re.Execute(str)
set Match = Matches(0)
ubb = ubb & Match & " "
str = Replace(str,"",""&vbcrlf)
re.Pattern="\
(.*)\<\/div>"
Set Matches = re.Execute(str)
set Match = Matches(0)
Dim TheLink
TheLink = Match
re.Pattern="href=s?(.[^>]*)"
TheLink = re.replace(TheLink,"href=""$1""")
ubb = ubb & TheLink
end function
if len(request("wd")) > 0 then
response.write dq(request("wd"))
end if
%>
index.asp
CODE:
<%
dim url,Wstr,we,wf,lm,si,rn,ie,ct,pn,cl
we=Request.QueryString("wd")
If we="" Then
Response.Write("
")
Response.Write Body
End if
%>
[Copy to clipboard]
Function.asp
CODE:
<%
Function GetHttpPage(HttpUrl)
If IsNull(HttpUrl)=True Or HttpUrl="$False$" Then
GetHttpPage="$False$"
Exit Function
End If
Dim Http
Set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",HttpUrl,False
Http.Send()
If Http.Readystate<>4 then
Set Http=Nothing
GetHttpPage="$False$"
Exit function
End if
GetHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
Set Http=Nothing
If Err.number<>0 then
Err.Clear
End If
End Function
Function BytesToBstr(Body,Cset)
Dim Objstream
Set Objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Function GetBody(ConStr,StartStr,OverStr,IncluL,IncluR)
If ConStr="$False$" or ConStr="" or IsNull(ConStr)=True Or StartStr="" or IsNull(StartStr)=True Or OverStr="" or IsNull(OverStr)=True Then
GetBody="$False$"
Exit Function
End If
Dim ConStrTemp
Dim Start,Over
ConStrTemp=Lcase(ConStr)
StartStr=Lcase(StartStr)
OverStr=Lcase(OverStr)
Start = InStrB(1, ConStrTemp, StartStr, vbBinaryCompare)
If Start<=0 then
GetBody="$False$"
Exit Function
Else
If IncluL=False Then
Start=Start+LenB(StartStr)
End If
End If
Over=InStrB(Start,ConStrTemp,OverStr,vbBinaryCompare)
If Over<=0 Or Over<=Start then
GetBody="$False$"
Exit Function
Else
If IncluR=True Then
Over=Over+LenB(OverStr)
End If
End If
GetBody=MidB(ConStr,Start,Over-Start)
End Function
%>