使用XMLHTTP组件最简单,代码如下:Sub main() Dim xmlHttp As Object
Set xmlHttp = CreateObject("MSXML2.XMLHTTP") xmlHttp.open "GET", "http://www.baidu.com", False xmlHttp.send If xmlHttp.readyState = 4 And xmlHttp.Status = 200 Then Debug.Print xmlHttp.responseText End If End Sub
Dim strHtml As String = Inet1.OpenURL("http://www.baidu.com", 0) 引用 Micosoft Internet Transfer Control '去除html '-------------------------------------------------------------------------------------------------- Public Function NoHtml(ByVal Str As String) As String Dim Reg As RegExp Set Reg = New RegExp Reg.IgnoreCase = True Reg.Global = True Reg.Pattern = "(\<.[^\<]*\>)" Str = Reg.Replace(Str, " ") Reg.Pattern = "(\<\/[^\<]*\>)" Str = Reg.Replace(Str, " ") NoHtml = Str Set Reg = Nothing End Function
搜索下mshtml取网页的资料,看是不是你要的那类。
Dim xmlHttp As Object
Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
xmlHttp.open "GET", "http://www.baidu.com", False
xmlHttp.send
If xmlHttp.readyState = 4 And xmlHttp.Status = 200 Then
Debug.Print xmlHttp.responseText
End If
End Sub
引用 Micosoft Internet Transfer Control
'去除html
'--------------------------------------------------------------------------------------------------
Public Function NoHtml(ByVal Str As String) As String
Dim Reg As RegExp
Set Reg = New RegExp
Reg.IgnoreCase = True
Reg.Global = True
Reg.Pattern = "(\<.[^\<]*\>)"
Str = Reg.Replace(Str, " ")
Reg.Pattern = "(\<\/[^\<]*\>)"
Str = Reg.Replace(Str, " ")
NoHtml = Str
Set Reg = Nothing
End Function