Ce qui suit est le code source, veuillez le nommer. Fichier ASP.
La copie de code est la suivante:
<Metahttp-Equiv = "Content-Type" Content = "Text / Html; charSet = GB2312">
<%
ifrequest ("action") = "1" puis
word = request ("word")
url = request ("url")
ifword <> "" alors
getCategories ()
ifurl <> "" alors
getCategories2 ()
endire
endire
endire
FunctionGetCategories ()
Response.Write ("<b> '" & Word & "' Le mot clé est parmi les 10 meilleurs sites Web du classement de recherche Google! </b> <br>")
onerrorresumenext
Dimoxmlhttp
Dimocategories
Dimbodytext
DIMPOS, POS1
SetOxMlHttp = CreateObject ("Microsoft.xmlhttp")
http = "http://www.google.com/search?q=" & word & "& hl = en-cn"
oxmlhttp.open "get", http, false
oxmlhttp.send
BodyText = oxmlhttp.ResponseBody
BodyText = ByTestObstr (BodyText, "UTF-8")
Pos = instr (bodyText, "<body")
pos1 = instr (bodyText, "</gody>")
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)
réponse.write ("t:" & thet & "<br>")
réponse.write ("u:" & theu & "<br> <hr>")
suivant
SetOxmlhttp = rien
iFerr.Number <> 0THEN
Il y a eu une réponse d'erreur.WRITE "Response.Write, Error Description:" & err.description & "<br> Error Source" & err.source
réponse.end ()
endire
Finition de fin
FunctionGetCategories2 ()
onerrorresumenext
Dimoxmlhttp'asobject
Dimocategories'sobject
Dimbodytext
DIMPOS, POS1
SetOxMlHttp = CreateObject ("Microsoft.xmlhttp")