Foxtable(狐表)用户栏目专家坐堂 → 求助:网页源码获取之后,不知道是不是遍历循环不对,居然只有一条数据,实际有77条数据,麻烦补充下循环遍历,谢谢!


  共有1880人关注过本帖平板打印复制链接

主题:求助:网页源码获取之后,不知道是不是遍历循环不对,居然只有一条数据,实际有77条数据,麻烦补充下循环遍历,谢谢!

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


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
求助:网页源码获取之后,不知道是不是遍历循环不对,居然只有一条数据,实际有77条数据,麻烦补充下循环遍历,谢谢!  发帖心情 Post By:2016/11/2 20:44:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:11.png
图片点击可在新窗口打开查看

代码如下:
Dim web As new System.Windows.Forms.WebBrowser
web.ScriptErrorsSuppressed = True
web.Navigate("http://search.jcrb.com/was5/web/search?page=1&channelid=263328&perpage=10000000&outlinepage=10000000")

Do Until web.ReadyState = 4 AndAlso web.document.GetElementsByTagName("table").count > 1
    Application.DoEvents
Loop

Dim str As String = ""
Dim tb1s = web.document.GetElementsByTagName("table")(4) '从第4个<Table>开始查找
For Each tb1 As object In tb1s.GetElementsByTagName("tr")'遍历TR'
    Dim sa = tb1.GetElementsByTagName("a")'获取A标签元素'
    If sa.count > 0 Then
        Dim a = sa(0)
        Dim Tel As String = a.InnerHtml
        Dim Parts1() As String = Tel.Split("</FONT>")
        str &= Parts1(0) & vbcrlf
        str &= a.GetAttribute("href") & vbcrlf
        Dim shijian As String= (FileSys.GetName(a.GetAttribute("href")).Insert(5,"-")).Insert(8,"-")
        Dim Parts() As String = shijian.Split("_")
        str & =Parts(0).Remove(0,1) & vbcrlf
    End If
Next

output.Show(str)


文章列表源码:
<Table width="980" align="center" border="0" cellpadding="0" cellspacing="5">
<tr>
<td class=f>
<font size="3"><a href="http://www.gzwengan.jcy.gov.cn/jcyw/201605/t20160505_1787530.shtml" target="_blank">加强与代表面对面沟通,进一步提高代表的满意率</font> </a>
<br><font size=-1><font color=#008000>2016.05.05&nbsp;&nbsp; 作者:</font> <br>
<br> 4月27日,瓮安县人民检察院陈德清副检察长和人大代表联络办公室的两名工作人员专程到中坪镇政府向第十六届人大代表?中坪镇人大主席王成伦汇报提案办理情况 <br></font>
</td>
</tr>
</Table>
[此贴子已经被作者于2016/11/2 20:53:15编辑过]

 回到顶部