<%
hehehe = hello ("http://mmsg.qq.com/cgi-bin/gddylist?type=13&sort=1&page=3", "<html>", "</html>", ".*(<tdwidth =" " 35%"" bgcolor = ""#[/dabcde] {6} ""> (.*) </Td>) [./ n]*"," <fontstyle = "" font-size: 9pt; "" color = blue> $ 2 </font> <br> ")
response.writehehe
FunctHhello (Strurl, StrStart, Strend, Patrn, Replstr)
Str = getbody (strurl)
Str = mymid (str, strstart, strend)
Str = ReplaceTest (Patrn, Replstr, Str)
Hello = str
Конечная функция
FunctionMymid (str, strStart, strend)
Ifstrstart = "" then
i = 0
Еще
i = instr (str, strstart)
Эндиф
Ifstrend = "" then
J = Лен (Str)
Еще
j = instr (i, str, strend)
Эндиф
Mymid = mid (str, i, j-i+1)
Конечная функция
FunctionReplacetest (Patrn, Replstr, Str1)
DimRegex, Match, Matches
SetRegex = newRegexp
regex.pattern = patrn
regex.ignorecase = true
regex.global = true
Setmatches = regex.execute (str1)
Foreachmatchinmatches
ReplaceTest = ReplaceTest®ex.Replace (Match.value, ReplySt)
Следующий
Конечная функция
Functiongetbody (url)
SetObjxml = createObject ("microsoft.xmlhttp")
Withobjxml
.Open "Get", url, false "", "" "
.Отправлять
Getbody =. -Responsebody
Энд
Getbody = bytestobstr (getbody, "gb2312")
SetObjxml = ничего
Конечная функция
Functionbytestobstr (strbody, codebase)
SetObjStream = server.createObject ("adodb.stream")
Withobjstream
.Type = 1
.Mode = 3
.Открыть
.Writestrody
.Position = 0
.Type = 2
.CHARSET = CODEBASE
Bytestobstr = .readtext
.Закрывать
Энд
Setobjstream = ничего
Конечная функция
%>
其他调用示例 :
hehehe = hello ("http://list.mp3.baidu.com/song/a.htm", "<tablewidth =" "90%" "border =" "0" "align =" "center" "cellPadding =" "3" "" 0 "0" "bgcolor ="#f5f5f5f5 ""> " , "<Divalign = center>", ".*(<Tdwidth =" "20%" "> <ahref =" ".*/. Htm" "target = _blank>) (.*) (</a> </td>) [./ n]*", "<fontstyle =" "font-size: 9pt;" "Color> $ 2 </$ 2 </$ 2 </$ 2