日期:2010-02-01 浏览次数:20880 次
将如下内容保存为ASP文件,运行查看既可,代码如下:
<%
bpn = request("bpn")
if(bpn = "") then
bpn = "0"
end if
intbpn = cint(bpn)
if request("action") = "1" then
word = request("word")
url = request("url")
if url="" then
url="aiyiweb.com"
end if
if word="" then
word="爱易学习网"
end if
getCategories()
getCategories2()
end if
Function getCategories()
response.write("<b>'"&word&"' 关键词在百度搜索排名中,前10位网站!</b><br>")
on error resume next
Dim oXMLHTTP
Dim oCategories
Dim BodyText
Dim Pos,Pos1
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
oXMLHTTP.open "GET","http://www.baidu.com/baidu?word="&word,False
oXMLHTTP.send
BodyText=oXMLHTTP.responsebody
BodyText=BytesToBstr(BodyText,"gb2312")
Pos=Instr(BodyText,"<body")
pos1=Instr(BodyText,"</body>")
BodyText=mid(BodyText,pos,pos1)
BodyText=split(BodyText,"<table")
st = 5
for i = 1 to 10
thei = st + i
Pos=Instr(BodyText(thei),"<td")
pos1=Instr(BodyText(thei),"</td>")
Body=mid(BodyText(thei),pos,len(BodyText(thei))-pos)
body1=split(body,"<br>")
title = body1(0)
theurl = body1(2)
theurl = replace(theurl,"上的更多结果","")
response.write ("T:"& title)
response.write ("<br>")
response.write ("U:"& theurl)
response.write ("<br><hr>")
next
Set oXMLHTTP = Nothing
if err.number<>0 then
response.write "出错了,错误描述:"&err.description & "<br>错误来源"& err.source
response.End()
end if
End Function
Function getCategories2()
on error resume next
Dim oXMLHTTP ' As Object
Dim oCategories ' As Object
Dim BodyText
Dim Pos,Pos1
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
out = 0
pn = 0
pp = 0
do while(true)
strurl="http://www.baidu.com/baidu?word="&word&"&pn="&cint(pn)+intbpn*10
//response.write(strurl&"<br>")
oXMLHTTP.open "GET",strurl,False
oXMLHTTP.send
BodyText=oXMLHTTP.responsebody
BodyText=BytesToBstr(BodyText,"gb2312")
Pos=Instr(BodyText,"<body")
pos1=Instr(BodyText,"</body>")
BodyText=mid(BodyText,pos,pos1)
BodyText=split(BodyText,"<table")
st = 5
thei = 0
for i = 1 to 10
thei = st + i
//response.write(thei)
Pos=Instr(BodyText(thei),"<td")
pos1=Instr(BodyText(thei),"</td>")
Body=mid(BodyText(thei),pos,len(BodyText(thei))-pos)
Pos3=Instr(Body,url)
if Pos3 > 0 then
pp = pn + i
out = 1
Exit For
end if
next
if out = 1 or pn = 90 then
exit do
end if
pn = cint(pn)+10
loop
if pp <> 0 then
response.write("<br><br>网站 <b>'"&url&"'</b> 在搜索关键词 <b>'"&word&"'</b> 时在百度中排名名次 第<b> "&pp+intbpn*10&" </b>位 ")
else
response.write("<br><br>网站 <b>'"&url&"'</b> 在搜索关键词 <b>'"&word&"'</b> 时在百度中排名名次 <font color=red>未在"&intbpn*10+1&"名到"&intbpn*10+100&"内</font>")
end if
Set oXMLHTTP = Nothing
if err.number<>0 then
response.write "出错了,错误描述:"&err.description & "<br>错误来源"& err.source
response.E