以下是源碼,請命名為. ASP文件.
複製代碼代碼如下:
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<%
ifrequest("action")="1"then
word=request("word")
url=request("url")
ifword<>""then
getCategories()
ifurl<>""then
getCategories2()
endif
endif
endif
FunctiongetCategories()
response.write("<b>'"&word&"'關鍵詞在Google搜索排名中,前10位網站!</b><br>")
onerrorresumenext
DimoXMLHTTP
DimoCategories
DimBodyText
DimPos,Pos1
SetoXMLHTTP=CreateObject("Microsoft.XMLHTTP")
http="http://www.google.com/search?q="&word&"&hl=zh-CN"
oXMLHTTP.open"GET",http,False
oXMLHTTP.send
BodyText=oXMLHTTP.responsebody
BodyText=BytesToBstr(BodyText,"UTF-8")
Pos=Instr(BodyText,"<body")
pos1=Instr(BodyText,"</body>")
BodyText=mid(BodyText,pos,pos1)
Pos=Instr(BodyText,"<div>")
BodyText=Mid(BodyText,Pos)
pos1=Instr(BodyText,"</div>")
BodyText=mid(BodyText,1,pos1)
'response.write("::::"&BodyText&"::::")
BodyText=split(BodyText,"<pclass=g>")
fori=1to10
Pos=Instr(BodyText(i),"</a>")
thet=Mid(BodyText(i),1,Pos+3)
Pos=Instr(BodyText(i),"<spandir=ltr>")
theu=Mid(BodyText(i),Pos)
pos1=Instr(theu,"</span>")
theu=mid(theu,1,pos1-1)
response.write("T:"&thet&"<br>")
response.write("U:"&theU&"<br><hr>")
next
SetoXMLHTTP=Nothing
iferr.number<>0then
response.write"出錯了,錯誤描述:"&err.description&"<br>錯誤來源"&err.source
response.End()
endif
EndFunction
FunctiongetCategories2()
onerrorresumenext
DimoXMLHTTP'AsObject
DimoCategories'AsObject
DimBodyText
DimPos,Pos1
SetoXMLHTTP=CreateObject("Microsoft.XMLHTTP")