老师
经过这几天的研究,基本把这个网站的内容全部都能弄下来了.但现在的问题就是卡在翻页上面,麻烦老师看看我的代码,明明翻页成功的了,但为什么网页的信息还是上一页的? 代码如下:
Dim url As String = "http://app1.nmpa.gov.cn/data_nmpa/face3/base.jsp?tableId=68&tableName=TABLE68&title=%E5%9B%BD%E4%BA%A7%E5%8C%96%E5%A6%86%E5%93%81&bcId=138009396676753955941050804482&CbSlDlH0=qAkIkGkuZdHuZdHuZ6RIDC.kpMdjYOsCXVXeBm1Aq69qqHW"
Dim web As New System.Windows.Forms.WebBrowser
web.ScriptErrorsSuppressed = True
web.Navigate(url)
Do Until web.ReadyState = 4 AndAlso web.Document.GetElementById("content").GetElementsByTagName("a").count > 0
Application.DoEvents
Loop
Dim ys As Integer = web.Document.GetElementById("goInt").GetAttribute("value") '第一页
For i As Integer = 0 To web.Document.GetElementById("content").GetElementsByTagName("a").count - 1
If web.Document.GetElementById("content").GetElementsByTagName("a")(i).innerText IsNot Nothing Then
Dim zd As String = web.Document.GetElementById("content").GetElementsByTagName("a")(i).innerText
zd = zd.trim()
Output.show(zd) '需要的内容
End If
Next
web.Document.GetElementById("goInt").SetAttribute("Value",2) '设成第二页
web.Document.GetElementById("content").GetElementsByTagName("table")(4).GetElementsByTagName("tr")(0).GetElementsByTagName("td")(6).InvokeMember("Click") '点击去指定的页
Do Until web.ReadyState = 4 AndAlso web.Document.GetElementById("goInt").GetAttribute("value") <> ys
Output.show(web.Document.GetElementsByTagName("a")(73).innerText)
Output.show(web.Document.GetElementById("goInt").GetAttribute("value"))
Application.DoEvents
Loop
Output.show(web.Document.GetElementById("goInt").GetAttribute("value")) '看当前的页数
For i As Integer = 0 To web.Document.GetElementById("content").GetElementsByTagName("a").count - 1
If web.Document.GetElementById("content").GetElementsByTagName("a")(i).innerText IsNot Nothing Then
Dim zd As String = web.Document.GetElementById("content").GetElementsByTagName("a")(i).innerText
zd = zd.trim()
Output.show(zd) '需要的内容
End If
Next
我output.show 出的页数 也是第2页,说明翻页成功了,但为什么两次网页上的内容是一样的? 请老师教一下 要怎么才能实现真的翻页? 多谢!