ต่อไปนี้เป็นซอร์สโค้ดโปรดตั้งชื่อ ไฟล์ ASP
การคัดลอกรหัสมีดังนี้:
<metahttp-equiv = "content-type" content = "text/html; charset = gb2312">>
-
ifrequest ("action") = "1" แล้ว
Word = Request ("Word")
url = คำขอ ("url")
ifword <> "" แล้ว
GetCategories ()
ifurl <> "" แล้ว
GetCategories2 ()
endif
endif
endif
functiongetCategories ()
Response.write ("<b> '" & word & "' คำหลักเป็นหนึ่งใน 10 อันดับแรกของเว็บไซต์ในการจัดอันดับการค้นหาของ Google! </b> <br>")
onerrorresumenext
dimoxmlhttp
หมวดหมู่ dimocategory
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 = instres (bodytext, "<body")
pos1 = instres (bodytext, "</body>")
bodytext = mid (bodytext, pos, pos1)
pos = instres (bodytext, "<div>")
bodytext = mid (bodytext, pos)
pos1 = instres (bodytext, "</div>")
bodytext = mid (bodytext, 1, pos1)
'Response.write ("::::" & bodytext & "::::")
bodytext = split (bodytext, "<pclass = g>")
fori = 1to10
pos = instres (bodytext (i), "</a>")
thet = mid (bodytext (i), 1, pos+3)
pos = instres (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>")
ต่อไป
setoxmlhttp = ไม่มีอะไร
iferr.number <> 0 แล้ว
มีการตอบสนองข้อผิดพลาดเขียน "response.write, ข้อผิดพลาดคำอธิบาย:" & err.description & "<br> แหล่งที่มาข้อผิดพลาด" & err.source
Response.end ()
endif
endfunction
functiongetCategories2 ()
onerrorresumenext
dimoxmlhttp'asobject
DiMocategories'AsObject
DimbodyText
dimpos, pos1
setoxmlhttp = createObject ("microsoft.xmlhttp"))