Foxtable(狐表)用户栏目专家坐堂 → 数据下载


  共有14187人关注过本帖树形打印复制链接

主题:数据下载

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/4/11 10:54:00 [显示全部帖子]

不要只贴代码,请上传具体项目测试。

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/4/11 14:38:00 [显示全部帖子]

上传具体实例说明你的问题,你要获取什么?


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/4/12 9:22:00 [显示全部帖子]

Dim dtb1 As New DataTableBuilder("数据下载日期表")
dtb1.AddDef("日期", Gettype(Date))
dtb1.AddDef("下载", Gettype( Boolean  ))
dtb1.Build()
MainTable= Tables("数据下载日期表")

Dim a As Integer
Dim b As Integer
Dim t As Integer
a = 1
b = 2
For t=1 To b
    CurrentTable.AddNew()
    CurrentTable.Current("日期")= Date.Today.AddDays(t-a)
Next

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 StartDate As Date
Dim web As new System.Windows.Forms.WebBrowser
For Each rw In Tables("数据下载日期表").Rows
    If rw("下载")=False Then
        StartDate = rw("日期")
        Dim y0 As String = StartDate.Year
        Dim m0 As String = StartDate.Month
        If m0.Length = 1 Then
            m0.PadLeft(2,"0")
        End If
        Dim d0 As String = StartDate.Day
        If d0.Length = 1 Then
            d0.PadLeft(2,"0")
        End If
        Dim str As String = y0 & "-" & m0 & "-" & d0 & "_" & y0 & "-" & m0 & "-" & d0
        str = "http://chart.cp.360.cn/kaijiang/kaijiang?lotId=255401&spanType=2&span=" & str
       
       
        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

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/4/12 14:49:00 [显示全部帖子]

Dim startDate As Date = "2018-4-12"
Dim endDate As Date = "2018-4-12"

Dim dtb1 As New DataTableBuilder("数据下载日期表")
dtb1.AddDef("日期", Gettype(Date))
dtb1.AddDef("下载", Gettype( Boolean  ))
dtb1.Build()

Dim d As Date = startDate
Do While d <= endDate
    Dim nr = Tables("数据下载日期表").addnew
    nr("日期")= d
    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 y0 As String = StartDate.Year
        Dim m0 As String = StartDate.Month
        If m0.Length = 1 Then
            m0.PadLeft(2,"0")
        End If
        Dim d0 As String = StartDate.Day
        If d0.Length = 1 Then
            d0.PadLeft(2,"0")
        End If
        Dim str As String = y0 & "-" & m0 & "-" & d0 & "_" & y0 & "-" & m0 & "-" & d0
        str = "http://chart.cp.360.cn/kaijiang/kaijiang?lotId=255401&spanType=2&span=" & str
       
       
        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


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/4/13 14:45:00 [显示全部帖子]

以下是引用yei在2018/4/13 13:22:00的发言:
甜老师,如果要实现实时抓取数据(就是网页一有新数据就马上下载到表)可以实现吗?

 

做一个定时器,定时抓取 http://www.foxtable.com/webhelp/scr/0657.htm

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/4/15 11:34:00 [显示全部帖子]

以下是引用yei在2018/4/14 22:34:00的发言:
刷新重新获取还是不行,今天到这个时段网页有100条数据了,可就是抓取不了,才抓取了几条数据。老师再帮我想想办法,谢谢了

 

代码不会有问题的,如果获取不正常,试试代码改成这样

 

str = "http://chart.cp.360.cn/kaijiang/kaijiang?lotId=255401&spanType=2&span=" & str & "&key=" & Rand.Next(100000)

 

如果还有问题,我今晚再测试。


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/4/15 15:55:00 [显示全部帖子]

改成

 

Dim startDate As Date = "2018-4-12"
Dim endDate As Date = "2018-4-12"
Dim dtb1 As New DataTableBuilder("数据下载日期表")
dtb1.AddDef("日期", Gettype(Date))
dtb1.AddDef("下载", Gettype( Boolean  ))
dtb1.Build()

Dim d As Date = startDate
Do While d <= endDate
    Dim nr = Tables("数据下载日期表").addnew
    nr("日期")= d
    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

               
        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


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/4/15 21:15:00 [显示全部帖子]

Dim startDate As Date = "2018-4-15"
Dim endDate As Date = "2018-4-15"
Dim dtb1 As New DataTableBuilder("数据下载日期表")
dtb1.AddDef("日期", Gettype(Date))
dtb1.AddDef("下载", Gettype( Boolean  ))
dtb1.Build()

Dim d As Date = startDate
Do While d <= endDate
    Dim nr = Tables("数据下载日期表").addnew
    nr("日期")= d
    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


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/4/16 8:49:00 [显示全部帖子]

以下是引用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


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/4/16 14:55:00 [显示全部帖子]

以下是引用yei在2018/4/16 13:26:00的发言:
做一个定时器执行动态抓取,日期的增加,不能避免16日的数据和17日数据的连接,动态抓取如何实现?

 

不理解你的意思,请用实例具体说明你的问题和你需要达到的效果。


 回到顶部
总数 15 1 2 下一页