ต่อไปนี้เป็นซอร์สโค้ดโปรดตั้งชื่อเป็นไฟล์. asp
การคัดลอกรหัสมีดังนี้:
-
bpn = คำขอ ("bpn")
ถ้า (bpn = "") แล้ว
bpn = "0"
endif
intbpn = cint (bpn)
ifrequest ("action") = "1" แล้ว
Word = Request ("Word")
url = คำขอ ("url")
ifword <> "" แล้ว
GetCategories ()
ifurl <> "" แล้ว
GetCategories2 ()
endif
endif
endif
functiongetCategories ()
response.write ("<b> '" & word & "' คำหลักเป็นหนึ่งใน 10 เว็บไซต์อันดับต้น ๆ ในการจัดอันดับการค้นหา Baidu! </b> <br>")
onerrorresumenext
dimoxmlhttp
หมวดหมู่ dimocategory
DimbodyText
dimpos, pos1
setoxmlhttp = createObject ("microsoft.xmlhttp"))
oxmlhttp.open "get", "http://www.baidu.com/baidu?word=" & word, false
oxmlhttp.send
bodytext = oxmlhttp.responsebody
bodytext = bytestobstr (bodytext, "GB2312")
pos = instres (bodytext, "<body")
pos1 = instres (bodytext, "</body>")
bodytext = mid (bodytext, pos, pos1)
bodytext = split (bodytext, "<table")
st = 5
fori = 1to10
thei = st+i
pos = instres (bodytext (thei), "<td")
pos1 = instres (bodytext (thei), "</td>")
body = mid (bodytext (thei), pos, len (bodytext (thei))-pos)
body1 = split (body, "<br>")
title = body1 (0)
Theurl = body1 (2)
TheURL = แทนที่ (TheURL, "ผลลัพธ์เพิ่มเติมเกี่ยวกับ", "")
Response.write ("t:" & title)
Response.write ("<br>")
Response.write ("u:" & theurl)
Response.write ("<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"))