以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  再次求助获取网页数据  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=107997)

--  作者:W1234
--  发布时间:2017/10/13 23:51:00
--  再次求助获取网页数据

我将参考的代码按我的理解改了一下,如下:


Dim web As New System.Windows.Forms.WebBrowser()
web.Navigate("http://hb.122.gov.cn/views/examappointpub.html")
Do Until web.ReadyState = 4
    Application.DoEvents
Loop



\'取数据
Dim Cols() As String = { "序号","考试日期","考试场地","考试场次","普通预约计划","优先预约计划","操作" }


Dim elems As object = web.Document.GetElementById("list_elem").GetElementsByTagName("tr")
Dim m As Integer = 0
For Each elem As object In elems
    Dim i As Integer = -1
   
    m = m + 1
    If m > 1 Then  \'因为网页的表格有标题,如果不判断,就会增加出一个空行
        Tables("考试预约计划表").AddNew
    End If
   
    Dim tdelems As object =  elem.GetElementsByTagName("td")
    For Each tdelem As object In tdelems
        i = i + 1
        Tables("考试预约计划表").Current(Cols(i)) = tdelem.Innertext
        
         
    Next
Next


 


 


不能实现导出网页https://hb.122.gov.cn/views/examappointpub.html的数据,再请版主指点一下,谢谢


--  作者:有点蓝
--  发布时间:2017/10/14 8:46:00
--  
请不要重复发帖

http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=107975