การคัดลอกรหัสมีดังนี้:
<%@language = "vbscript" codePage = "936"%>
<! doctypehtmlpublic "-// w3c // dtdhtml4.01transitional // en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<metahttp-equiv = "content-type" content = "text/html; charset = gb2312">>
<tite> โปรแกรมสอบถามค่า Google PRATION </title>
</head>
<body> <h3> ป้อน URL และสอบถามค่า Googlepagerank </h3>
<formName = "form1" method = "post" action = "? act = ok">
<p> ป้อน URL
<inputType = "text" name = "Domain">
<inputType = "ส่ง" name = "ส่ง" value = "ส่ง">
</p>
</form>
-
iftrim (request.querystring ("Act")) = "ตกลง" แล้ว
domain = trim (request.form ("โดเมน"))
ifdomain <> "" แล้ว
Response.write ("<b>" & โดเมน & "</b> ของค่า Google Pagerank คือ <fontColor = red>" & getPR (โดเมน) & "</font>")
endif
endif
functiongetpr (โดเมน)
getContent = getUrl ("http://so.5eo.com/pr/rank.asp?domain=" & Domain)
getPrline = regexptext (getContent, "get.* (// d).* คะแนนใน GooglePagerank คะแนนเต็ม 10 คะแนนคะแนน")))
getpr = regexptext (getprline, "// s // d // s")
endfunction
functionbsstr (vin)
Dimstrreturn, I, ThischArcode, InnerCode, Hight8, Low8, NextCharcode
strreturn = ""
fori = 1tolenb (vin)
thischArcode = ascb (midb (vin, i, 1))
ifthisCharcode <& h80 จากนั้น
strreturn = Strreturn & Chr (ThisCharcode)
อื่น
NextCharcode = ASCB (MIDB (VIN, I+1,1)))
strreturn = strreturn & chr (clng (thischarcode)*& h100+cint (nextcharcode))
i = i+1
endif
ต่อไป
bstr = streturn
endfunction
functiongeturl (URL)
setRetrieval = server.createObject ("microsoft.xmlhttp"))
เกี่ยวกับการแก้ไข
.Open "Get", url, false
.SetRequestHeader "ประเภทเนื้อหา", "แอปพลิเคชัน/x-www-form-urlencoded"
.ส่ง
getURL = .ResponseBody
จบลงด้วย
setRetrieval = ไม่มีอะไร
getUrl = bstr (getUrl)
endfunction
functionReGExpText (Strng, regstr)
'Dimregex, Match, Matches' สร้างตัวแปร
setregex = newregexp 'สร้างนิพจน์ทั่วไป
regex.pattern = โหมด set regstr '
regex.ignorecase = true 'ตั้งค่าไม่ว่าจะเป็นตัวพิมพ์เล็กหรือไม่