补一个函数
Function GetHtml(ByVal url$, Optional ByVal Coding$ = "gb2312")
On Error Resume Next
Dim ObjXML As Object
Set ObjXML = CreateObject("Microsoft.XMLHTTP")
With ObjXML
.open "Get", url, False, "", ""
.setRequestHeader "If-Modified-Since", "0"
.send
GetHtml = .responseBody
End With
GetHtml = BytesToBstr(GetHtml, Coding)
Set ObjXML = Nothing
End Function
版主不给解答 我来
Private Sub Command1_Click()
Dim oDov As HTMLDocument, iDiv As HTMLDivElement
Dim date1(1 To 50) As String, result(1 To 50) As String
Set oDov = New HTMLDocument
url = "http://www.lottery.gov.cn/lottery/qxc/History.aspx?p=1"
oDov.body.innerHTML = GetHtml(url, "utf-8")
Set iDiv = oDov.getElementsByTagName("tbody")(8)
For i = 1 To 49
date1(i) = iDiv.childNodes(i + 1).childNodes(0).innerText
result(i) = iDiv.childNodes(i + 2).childNodes(0).innerText
Text1.Text = Text1.Text & vbCrLf & date1(i) & "--" & result(i)
Next i
End Sub
'==============================================
'将网页数据进行转码
'==============================================
Function BytesToBstr(strBody, CodeBase)
On Error Resume Next
Dim objstream As Object
Set objstream = CreateObject("Adodb.Stream")
With objstream
.Type = 1
.Mode = 3
.open
.Write strBody
.position = 0
.Type = 2
.Charset = CodeBase
BytesToBstr = .ReadText
.Close
End With
Set objstream = Nothing
End Function
'==============================================