以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]错在哪里? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=98745) |
-- 作者:dqlgood -- 发布时间:2017/4/6 11:39:00 -- [求助]错在哪里? 如题:要获取“http://data.10jqka.com.cn/market/longhu/”网页的数据代码如下: Dim web As new System.Windows.Forms.WebBrowser web.ScriptErrorsSuppressed = True web.Navigate("http://data.10jqka.com.cn/market/longhu/") Do Until web.ReadyState = 4 Application.DoEvents Loop Dim t = web.Document.GetElementById("ggmx") t.SetAttribute("Value","2017-03-28") For Each input As object In web.Document.GetElementById("ggmx").GetElementsByTagName("input") If input.GetAttribute("ClassName") = "m_text_date startday" Then input.InvokeMember("click") Exit For End If Next Do Until web.Document.GetElementById("ggmx").GetElementsByTagName("span")(0).InnerText = "2017-03-28" Application.DoEvents Loop \'去掉上面红色代码运行可以抓取到,最后一次更新的数据,设想用红色代码模拟点击日期选择框,实现日期选择功能, \'但始终没能修改成功,不知是否可以?也不知代码错在哪里?请老师指正. For Each div As object In web.Document.GetElementsByTagName("div") If div.GetAttribute("ClassName") = "stockcont" Then For Each tr As object In div.GetElementsByTagName("tr") Dim str As String = "" Dim tds = tr.GetElementsByTagName("td") For i As Integer = 0 To tds.count - 1 str &= tds(i).InnerText & " " Next output.show(str) Next End If Next |
-- 作者:有点色 -- 发布时间:2017/4/6 12:09:00 -- 直接这样取,即可 http://data.10jqka.com.cn/ifmarket/lhbggxq/report/2017-04-05/
|
-- 作者:dqlgood -- 发布时间:2017/4/14 16:56:00 -- 谢谢! 我是菜鸟,请指点,如何才能得到此好像是“HTML”网页地址,我查了网页“网页源代码”和“开发人员工具”也不得其法。 要获取“http://data.10jqka.com.cn/market/lhbyyb/orgcode/CTZQGFYXGSWLDHBLZQYYB/”网页数据, 不知是否还可以用您给的方法,但我还是用贵网“专家堂”指点的方法克隆了一段代码,还是不得要领, 仅能获得首页数据,请老师指点。 Dim web As new System.Windows.Forms.WebBrowser web.Navigate("http://data.10jqka.com.cn/market/lhbyyb/orgcode/CTZQGFYXGSWLDHBLZQYYB/") Do Until web.ReadyState = 4 Application.DoEvents Loop Dim pg = web.Document.GetElementById("yybid") pg.SetAttribute("data-param", "3") For Each a As object In web.Document.GetElementById("yybid").GetElementsByTagName("a") If a.GetAttribute("ClassName") = "changePage" Then a.InvokeMember("data-param") Exit For End If Next For Each div As object In web.Document.GetElementsByTagName("div") If div.GetAttribute("ClassName") = "cur" Then Dim sa = div.GetElementsByTagName("a") Do Until sa(0).InnerText = 3 Application.DoEvents Loop ElseIf div.GetAttribute("ClassName") = "zdph" Then For Each tr As object In div.GetElementsByTagName("tr") Dim str As String = "" Dim tds = tr.GetElementsByTagName("td") For i As Integer = 0 To tds.count - 1 str &= tds(i).InnerText & " " Next output.show(str) Next End If Next |
-- 作者:有点色 -- 发布时间:2017/4/14 17:01:00 -- 参考
|