代码如下,本来是一个asp网页用的,我稍微改了下放vb里面,但是第一次运行能得到哦源代码,其余的都是历史记录.....麻烦帮看看
Function getHTTPPage(url)
Dim Http
Set Http = CreateObject("MSXML2.XMLHTTP")
Http.Open "GET", url, False
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 FunctionFunction 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 Command1_Click()
html = getHTTPPage("http://www.chengdu.cc")
Text1.Text = html
html = "xxxxx"
End Sub