欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

百度小偷

程序员文章站 2022-05-18 12:52:34
<%function bytes2bstr(vin)strreturn = ""for i = 1 to lenb(vin)thischarcode = ascb(m...

<%
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}","<br>")
str = replace(str,vbcrlf,"<br>")
str = replace(str,"<br> <br>","<br>")
str = replace(str,"<br><br>","<br>")
str = replace(str,"<br><br>","<br>")
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>","{br}")
str = replace(str,"</td>","</td>"&vbcrlf)
str = replace(str,"<td",vbcrlf&"<td")

dim re,match,matches
set re = new regexp
re.global = true
re.ignorecase = true

re.pattern=".*\<td class=f>(.*)\<\/td>"

set matches = re.execute(str)

for each match in matches
ubb=ubb&br(match.value)
next
re.pattern="(\- \<a .[^\<]*>百度快照\<\/a>)"
ubb = re.replace(ubb,"")
re.pattern="(\<a class=""m"".[^\<]*>.[^\<]*\<\/a>)"
ubb = re.replace(ubb,"")
re.pattern="(\<font color=#008000>.[^\<]*\<\/font>)"
ubb = re.replace(ubb,"<hr>") '每一条信息的间隔
ubb = replace(ubb,"<td class=f>","")
ubb = replace(ubb,"</td>","")
ubb = br(ubb)


re.pattern="(找到相关网页.*秒)"
set matches = re.execute(str)
set match = matches(0)
ubb = ubb & match & "<br>"

str = replace(str,"</div>","</div>"&vbcrlf)


re.pattern="\<div class=""p"">(.*)\<\/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
%>
<form method=post action="?">
<input type="text" name="wd"> <input type="submit">
</form>