Foxtable(狐表)用户栏目专家坐堂 → 网页取数


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

主题:网页取数

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


加好友 发短信
等级:三尾狐 帖子:658 积分:7890 威望:0 精华:0 注册:2013/12/11 17:49:00
网页取数  发帖心情 Post By:2019/1/14 12:05:00 [只看该作者]

http://www.yyfdc.com.cn/list_clf_New.aspx

请问老师  从网页上取数  点了下一个 取数还是第一页的内容   我要怎么把下一页
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:网页取数.rar

的内容也获取到表格?

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/1/14 12:19:00 [只看该作者]

改成

 

Dim wy As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
Dim t1 As WinForm.Table = e.Form.Controls("Table1")

Dim web As System.Windows.Forms.WebBrowser = wy.basecontrol
'web.ScriptErrorsSuppressed = True
'web.Navigate(wy.Address)
'Do Until web.ReadyState = 4
'    Application.DoEvents
'Loop

Dim Cols() As String = {"序号","区域","坐落","面积","协议价格","成交日期" }

Dim elems As object = web.Document.GetElementById("grid_list").GetElementsByTagName("tr")

Dim m As Integer = 0
Dim k As Integer
For Each elem As object In elems
    Dim i As Integer = -1
    m = m + 1
    If m >=2 And  m<= elems.count  Then  '因为网页的表格有标题,如果不判断,就会增加出一个空行
    

            t1.Table.AddNew
  Dim tdelems As object =  elem.GetElementsByTagName("td")

            For Each tdelem As object In tdelems
                i = i + 1
                t1.Table.Current(Cols(i)) = tdelem.Innertext
            Next

       
    End If
Next


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


加好友 发短信
等级:三尾狐 帖子:658 积分:7890 威望:0 精华:0 注册:2013/12/11 17:49:00
  发帖心情 Post By:2019/1/14 12:34:00 [只看该作者]

谢谢老师   如果要循环读取所有页面 的内容要怎么写

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/1/14 14:54:00 [只看该作者]

Dim wy As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
Dim t1 As WinForm.Table = e.Form.Controls("Table1")

Dim web As System.Windows.Forms.WebBrowser = wy.basecontrol
'web.ScriptErrorsSuppressed = True
'web.Navigate(wy.Address)


Dim Cols() As String = {"序号","区域","坐落","面积","协议价格","成交日期" }
Dim Innertext = ""
Dim pg As Integer = 1
Do
    innertext = web.Document.GetElementById("grid_list").Innertext
    Dim elems As object = web.Document.GetElementById("grid_list").GetElementsByTagName("tr")
    Dim m As Integer = 0
    Dim k As Integer
    For Each elem As object In elems
        Dim i As Integer = -1
        m = m + 1
        If m >=2 And  m<= elems.count  Then  '因为网页的表格有标题,如果不判断,就会增加出一个空行
            t1.Table.AddNew
            Dim tdelems As object =  elem.GetElementsByTagName("td")
            For Each tdelem As object In tdelems
                i = i + 1
                t1.Table.Current(Cols(i)) = tdelem.Innertext
            Next
        End If
    Next
    Dim aas = web.Document.GetElementById("paging").GetElementsByTagName("a")
    aas(aas.count-1).InvokeMember("click")
    Do Until web.ReadyState = 4 AndAlso web.Document.GetElementById("grid_list").Innertext <> Innertext
        Application.DoEvents
    Loop
    pg += 1
Loop While pg <= 8 '测试8页数据


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


加好友 发短信
等级:三尾狐 帖子:658 积分:7890 威望:0 精华:0 注册:2013/12/11 17:49:00
  发帖心情 Post By:2019/1/14 15:29:00 [只看该作者]

谢谢老师

 回到顶部