<%
url="http://www.mvgod.com/theater/ChongQing/BLWH/" '//定义要获取源代码的网址,一般是通过变量传递过来
HTMLCODE=getHTTPPage(url) '//获取源代码的函数
Function getHTTPPage(url)
dim objXML
set objXML=createobject("MSXML2.SERVERXMLHTTP.3.0") '调用XMLHTTP组件,测试空间是否支持XMLHTTP
objXML.open "GET",url,false 'false表示以同步的方式获取网页代码,了解什么是同步?什么是异步?
objXML.send() '发送
getHTTPPage=bBytesToBstr(objXML.responseBody)'返回信息,同时用函数定义编码
set objXML=nothing'关闭
End Function
Function bBytesToBstr(body)
dim objstream
set objstream = CreateObject("adodb.stream") '//调用adodb.stream组件
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "UTF-8" '转换原来默认的UTF-8编码转换成GB2312编码,否则直接用XMLHTTP调用有中文字符的网页得到的将是乱码
bBytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
end Function
Function RegExpTest(patrn, strng)
Dim regEx, retVal '建立变量。
Set regEx = New RegExp '建立正则表达式。
regEx.Pattern = patrn '设置模式。
regEx.IgnoreCase = False '设置是否区分大小写。
regEx.Global = True
Set retVal = regEx.Execute(strng) '执行搜索测试。
For Each Match in retVal '遍历匹配集合。
RetStr = RetStr & Match.Value
Next
RegExpTest = RetStr
End Function
response.write RegExpTest("<table cellpadding=""1"" cellspacing=""1"" border=""0"" id=""guide""([\s\S]*)</table>", HTMLCODE)
%>
asp下载html匹配
最新推荐文章于 2021-06-07 14:50:09 发布