可以下载的了,以前的代码下载效果更好,用旧代码应该怎样改?望老师指点。
以下内容为程序代码:
1 Dim startDate As Date = "2018-9-12"
2 Dim endDate As Date = "2018-9-12"
3 Dim dt As DataTable = DataTables("数据下载日期表")
4 Dim d As Date = startDate
5 Do While d <= endDate
6 If d > Date.today Then
7 msgbox("不能查找大于今天的数据" & d)
8 Else
9 Dim fdr As DataRow = dt.Find("日期 = #" & d & "#")
10 If fdr Is Nothing Then
11 fdr = dt.AddNew
12 fdr("日期") = d
13 End If
14 End If
15 d = d.AddDays(1)
16 Loop
17 Dim dt2 As DataTable = DataTables("老时时彩")
18 Dim web As new System.Windows.Forms.WebBrowser
19 For Each rw As DataRow In dt.Select("下载 = false")
20 StartDate = rw("日期")
21 Dim str As String = Format(startDate, "yyyy-MM-dd_yyyy-MM-dd")
22 str = "https://www.km28.com/lottery-gp/cqssc/2018-09-12.html=" & str & "&key=" & Rand.Next(10000)
23
24 web.Navigate(str)
25 Do Until web.ReadyState = 4
26 Application.DoEvents
27 Loop
28 Dim i As Integer = 0
29 For Each dl As object In web.Document.GetElementById("his-tab").GetElementsByTagName("table")
30 If dl.getattribute("classname") Like "tr-odd*" Then
31 For Each tr As object In dl.GetElementsByTagName("tr")
32 Dim tds = tr.GetElementsByTagName("td")
33 If tds.count >= 5 AndAlso tds(0).Innertext > "" Then
34 Dim ndr As DataRow = dt2.Find("日期=#" & startDate & "# and 期号='" & tds(0).innertext & "'")
35 If ndr Is Nothing Then ndr = dt2.addnew
36 ndr("日期") = startDate
37 ndr("期号") = tds(0).innertext
38 ndr("开奖号") = tds(1).innertext
39 End If
40 Next
41 End If
42 Next
43 If StartDate < Date.today Then
44 rw("下载") = True
45 End If
46 Next