'此代码由“正则测试工具 v1.1.33”自动生成,请直接调用TestReg过程 Private Sub TestReg() Dim strData As String Dim reg As Object Dim matchs As Object strData = getHtmlStr("http://www.baidu.com/") Set reg = CreateObject("vbscript.regExp") reg.IgnoreCase = True reg.Pattern = "<title>(.*)</title>" Set matchs = reg.Execute(strData) If matchs.Count > 0 Then MsgBox matchs(0).SubMatches(0) End SubPrivate Function getHtmlStr(strUrl As String) As String Dim XmlHttp As Object Set XmlHttp = CreateObject("Microsoft.XMLHTTP") XmlHttp.Open "GET", strUrl, False XmlHttp.send getHtmlStr = StrConv(XmlHttp.ResponseBody, vbUnicode) Set XmlHttp = Nothing End Function
Private Sub TestReg()
Dim strData As String
Dim reg As Object
Dim matchs As Object strData = getHtmlStr("http://www.baidu.com/") Set reg = CreateObject("vbscript.regExp")
reg.IgnoreCase = True
reg.Pattern = "<title>(.*)</title>"
Set matchs = reg.Execute(strData)
If matchs.Count > 0 Then MsgBox matchs(0).SubMatches(0)
End SubPrivate Function getHtmlStr(strUrl As String) As String
Dim XmlHttp As Object
Set XmlHttp = CreateObject("Microsoft.XMLHTTP")
XmlHttp.Open "GET", strUrl, False
XmlHttp.send
getHtmlStr = StrConv(XmlHttp.ResponseBody, vbUnicode)
Set XmlHttp = Nothing
End Function
哦,难道winsock也禁止使用?