以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 网页取数 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=190033) |
-- 作者:aidimeng -- 发布时间:2024/1/12 11:47:00 -- 网页取数 此主题相关图片如下:微信截图_20240112114527.png Dim Cols() As String = {"姓名", "表具编号", "imei", "地址", "用水日期", "日累计量" } Dim elems As object = web.Document.GetElementById("layui-table").GetElementsByTagName("tr") 是这样写吗
|
-- 作者:有点蓝 -- 发布时间:2024/1/12 12:00:00 -- for each a as object in web.Document.GetElementsByTagName("table") if a.GetAttribute("class") = "layui-table" Dim elems As object = a.GetElementsByTagName("tr") …… next
|
-- 作者:aidimeng -- 发布时间:2024/1/12 12:18:00 -- For Each a As Object In web.Document.GetElementsByTagName("table") If a.GetAttribute("class") = "layui-table" Then Dim elems As Object = a.GetElementsByTagName("tr") Dim m As Integer = 0 Dim k As Integer MessageBox.Show("1") For Each elem As Object In elems Dim i As Integer = -1 m = m + 1 If m >= 2 And m <= elems.count Then \'因为网页的表格有标题,如果不判断,就会增加出一个空行 t1.Table.AddNew Dim tdelems As Object = elem.GetElementsByTagName("td") For Each tdelem As Object In tdelems \' i = i + 1 \' t1.Table.Current(Cols(i)) = tdelem.Innertext MessageBox.Show(tdelem.Innertext) Next End If Next End if MessageBox.Show("13") ----程序执行这里 Next 我理解的逻辑很清晰的,先取到table标签的集合,在找class=layui-table 的table 但就是找不到
[此贴子已经被作者于2024/1/12 12:52:58编辑过]
|
-- 作者:有点蓝 -- 发布时间:2024/1/12 13:36:00 -- 自己加代码调试,看找到的都是什么东西 HtmlDocument 各种用法自行学学:https://learn.microsoft.com/zh-cn/dotnet/api/system.windows.forms.htmldocument?view=netframework-4.0
|
-- 作者:aidimeng -- 发布时间:2024/1/12 21:40:00 -- Dim tbs As Object = web.Document.GetElementsByTagName("table") \'MessageBox.Show(“1”) ‘如果增加这阁语句,后面的 MessageBox.Show(a.GetAttribute("classname")) 显示 “layui-table”。注释这句代码,后面就没有任何提示 For Each a As Object In tbs MessageBox.Show(a.GetAttribute("classname")) If a.GetAttribute("classname") = "layui-table" Then Dim elems As Object = a.GetElementsByTagName("tr") MessageBox.Show("1") End If Next 就想知道为什么会这样呢 \'MessageBox.Show(“1”) 启到什么作用呢
[此贴子已经被作者于2024/1/12 21:42:46编辑过]
|
-- 作者:有点蓝 -- 发布时间:2024/1/13 8:58:00 -- 我也不知道为什么,完整代码发上来看看 |