已知网页表格id为class怎么获取表格和表格里面的内容
就是遍历这个表格所有单元
必须用vb6.0的webbrowser或mshtml控件
尽量给完整代码,
谢谢。
代码走到Set Table = doc.getElementsByID("class")出现错误。
张海老师你用一个html文件测试这段代码了吗?
vb已知网页表格id怎么获取表格
答案:2 悬赏:0 手机版
解决时间 2021-02-15 00:48
- 提问者网友:未信
- 2021-02-14 02:33
最佳答案
- 五星知识达人网友:第幾種人
- 2021-02-14 03:14
笔误getElementById
引用microsoft html object library
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim doc As MSHTML.HTMLDocument
Set doc = WebBrowser1.Document
Dim Tables As IHTMLElementCollection
Dim Table As IHTMLTable
Set Table = doc.getElementById("class")
Dim Row As HTMLTableRow, Cell As HTMLTableCell
Set Row = Table.rows.Item(1)
Set Cell = Row.cells.Item(0)
MsgBox Cell.innerText
End Sub
引用microsoft html object library
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim doc As MSHTML.HTMLDocument
Set doc = WebBrowser1.Document
Dim Tables As IHTMLElementCollection
Dim Table As IHTMLTable
Set Table = doc.getElementById("class")
Dim Row As HTMLTableRow, Cell As HTMLTableCell
Set Row = Table.rows.Item(1)
Set Cell = Row.cells.Item(0)
MsgBox Cell.innerText
End Sub
全部回答
- 1楼网友:由着我着迷
- 2021-02-14 03:26
那要看表格的类型
有的表格是只读的
有的则是只写入的
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯