以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  网页取数  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=130134)

--  作者:lshshlxsh
--  发布时间:2019/1/14 12:05:00
--  网页取数
http://www.yyfdc.com.cn/list_clf_New.aspx

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

的内容也获取到表格?
--  作者:有点甜
--  发布时间: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
--  发布时间:2019/1/14 12:34:00
--  
谢谢老师   如果要循环读取所有页面 的内容要怎么写
--  作者:有点甜
--  发布时间: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
--  发布时间:2019/1/14 15:29:00
--  
谢谢老师