以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 求助:大红袍老师 还是网页列表分页问题 请多多费心了 谢谢! (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=84905) |
||||
-- 作者:李孝春 -- 发布时间:2016/5/12 19:32:00 -- 求助:大红袍老师 还是网页列表分页问题 请多多费心了 谢谢! http://www.gzwengan.jcy.gov.cn/gzdt 这个是文章列表地址: 下述代码想获取文章列表的页数 Dim web As new System.Windows.Forms.WebBrowser web.ScriptErrorsSuppressed = True web.Navigate("http://www.gzwengan.jcy.gov.cn/gzdt/") Do Until web.ReadyState = 4 Application.DoEvents Loop Dim pg = web.Document.GetElementById("prevPage ").GetElementsByTagName("a") Dim mpg As Integer = 1 If pg.count > 1 Then mpg = pg(pg.count-2).Innertext output.show(mpg) End If For i As Integer = 1 To mpg web.Navigate( "http://www.gzwengan.jcy.gov.cn/gzdt/index_" & i & ".shtml") Do Until web.ReadyState = 4 Application.DoEvents Loop \'Dim i As Integer = 0 \'Dim tb1s = web.document.GetElementsByTagName("table")(36) \'For Each tb1 As object In tb1s.GetElementsByTagName("tr") \'Dim sa = tb1.GetElementsByTagName("a") \'If sa.count > 0 Then \'Dim a = sa(0) \'Dim dr As DataRow = DataTables("官网文章").AddNew() \'Dim fwdw As WinForm.ComboBox = e.Form.Controls("ComboBox1") \'Dim lmfl As WinForm.ComboBox = e.Form.Controls("ComboBox2") \'dr("单位") = fwdw.Value \'dr("文章标题") = a.innertext \'dr("文章分类") =lmfl.Value \'dr("网址") = a.GetAttribute("href") \'Dim shijian As String = (FileSys.GetName(a.GetAttribute("href")).Insert(5,"-")).Insert(8,"-") \'Dim Parts() As String = shijian.Split("_") \'dr("发布时间") =Parts(0).Remove(0,1) \'End If Next \'\'Next 代码运行报错: 下面是网页代码中显示页数的代码: |
||||
-- 作者:大红袍 -- 发布时间:2016/5/12 19:51:00 -- 无语,不要照搬啊。 |
||||
-- 作者:大红袍 -- 发布时间:2016/5/12 20:02:00 -- Dim web As new System.Windows.Forms.WebBrowser Dim pg = web.Document.GetElementById("num") |
||||
-- 作者:李孝春 -- 发布时间:2016/5/13 8:58:00 -- 回复:(大红袍)Dim web As new System.Windows.Form... 大红袍老师 上述代码执行无结果 执行下面的代码后死机 Dim web As new System.Windows.Forms.WebBrowser web.ScriptErrorsSuppressed = True Dim lmdz As WinForm.ComboBox = e.Form.Controls("ComboBox3") web.Navigate(lmdz.Value) \'web.Navigate(http://www.gzwengan.jcy.gov.cn/gzdt/) Do Until web.ReadyState = 4 Application.DoEvents Loop Dim pg = web.Document.GetElementById("num") pg.SetAttribute("Value", 1) Dim inputs = web.Document.GetElementsByTagName("input") For Each input As object In inputs If input.GetAttribute("type") = "submit" Then input.InvokeMember("click") Do Until web.document.GetElementsByTagName("table").count > 36 Application.DoEvents Loop ’output.show(web.documenttext) End If \'Dim i As Integer = 0 Dim tb1s = web.document.GetElementsByTagName("table")(36) For Each tb1 As object In tb1s.GetElementsByTagName("tr") Dim sa = tb1.GetElementsByTagName("a") If sa.count > 0 Then Dim a = sa(0) Dim dr As DataRow = DataTables("官网文章").AddNew() Dim fwdw As WinForm.ComboBox = e.Form.Controls("ComboBox1") Dim lmfl As WinForm.ComboBox = e.Form.Controls("ComboBox2") dr("单位") = fwdw.Value dr("文章标题") = a.innertext dr("文章分类") =lmfl.Value dr("网址") = a.GetAttribute("href") Dim shijian As String = (FileSys.GetName(a.GetAttribute("href")).Insert(5,"-")).Insert(8,"-") Dim Parts() As String = shijian.Split("_") dr("发布时间") =Parts(0).Remove(0,1) End If Next Next
|
||||
-- 作者:大红袍 -- 发布时间:2016/5/13 9:36:00 -- Dim web As new System.Windows.Forms.WebBrowser Do Until web.ReadyState = 4
|
||||
-- 作者:李孝春 -- 发布时间:2016/5/13 9:48:00 -- 回复:(大红袍)Dim web As new System.Windows.Form... 不知道是不是网速问题 还是代码问题 上述代码运行后 速度超慢 至少近两分钟才会有结果 如果遇见数据多的话 那不是很麻烦? 有没有办法改进呢?
|
||||
-- 作者:大红袍 -- 发布时间:2016/5/13 9:56:00 -- 我测试,没有任何问题。
你把你所有的foxtable项目先关闭后再测试。 |