VB用XML读取网页内容
Function getHTTPPage(Url)
Dim Http
Set Http = CreateObject("MSXML2.XMLHTTP")
Http.Open "GET", Url, False
a = Http.send()
If Http.readystate <> 4 Then
Exit Function
End If
getHTTPPage = BytesToBstr(Http.responseBody, "GB2312")
Set Http = Nothing
If Err.Number <> 0 Then Err.Clear
End Function
Function BytesToBstr(body, Cset)
Dim objstream
Set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode = 3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function
Private Sub Form_Load()
Dim Url, Html
Url = "要访问的网址"
MsgBox getHTTPPage(Url) '弹出对话框显示网站内容
End Sub