以下是引用yei在2018/4/16 7:35:00的发言:
现在还有个小问题:当下载结束日期往前推一天(设置为17日),会出现17日未有数据的条数会复制今天有数据的条数数据。
不能查超过今天的日期的数据的。你可以加入提示
Dim startDate As Date = "2018-4-15"
Dim endDate As Date = "2018-4-17"
Dim dtb1 As New DataTableBuilder("数据下载日期表")
dtb1.AddDef("日期", Gettype(Date))
dtb1.AddDef("下载", Gettype( Boolean ))
dtb1.Build()
Dim d As Date = startDate
Do While d <= endDate
If d > Date.today Then
msgbox("不能查找大于今天的数据" & d)
Else
Dim nr = Tables("数据下载日期表").addnew
nr("日期")= d
End If
d = d.AddDays(1)
Loop
Dim dtb2 As New DataTableBuilder("老时时彩")
dtb2.AddDef("日期", Gettype(Date))
dtb2.AddDef("期号", Gettype(String), 32)
dtb2.AddDef("开奖号", Gettype(String), 32)
dtb2.AddDef("十位", Gettype(String), 32)
dtb2.AddDef("个位", Gettype(String), 32)
dtb2.AddDef("后三", Gettype(String), 32)
dtb2.Build()
MainTable= Tables("老时时彩")
Dim rw As Row
Dim web As new System.Windows.Forms.WebBrowser
For Each rw In Tables("数据下载日期表").Rows
If rw("下载")=False Then
StartDate = rw("日期")
Dim str As String = Format(startDate, "yyyy-MM-dd_yyyy-MM-dd")
str = "http://chart.cp.360.cn/kaijiang/kaijiang?lotId=255401&spanType=2&span=" & str & "&key=" & Rand.Next(10000)
web.Navigate(str)
Do Until web.ReadyState = 4
Application.DoEvents
Loop
Dim i As Integer = 0
For Each dl As object In web.Document.GetElementById("his-tab").GetElementsByTagName("table")
If dl.getattribute("classname") Like "tr-odd*" Then
For Each tr As object In dl.GetElementsByTagName("tr")
Dim tds = tr.GetElementsByTagName("td")
If tds.count >= 5 AndAlso tds(0).Innertext > "" Then
Dim ndr As DataRow = DataTables("老时时彩").addnew
ndr("日期") = startDate
ndr("期号") = tds(0).innertext
ndr("开奖号") = tds(1).innertext
End If
Next
End If
Next
End If
Next