我正在使用 Visual Basic 中的 webkit 开源引擎浏览器。我想获取加载网页中包含的 html 标签,但是当我尝试使用 GetElementsByTagName 命令时,它总是什么都不返回。
你有什么想法?
提前致谢。马西莫
我正在使用 Visual Basic 中的 webkit 开源引擎浏览器。我想获取加载网页中包含的 html 标签,但是当我尝试使用 GetElementsByTagName 命令时,它总是什么都不返回。
你有什么想法?
提前致谢。马西莫
我不确定 VB,但我使用 C# 通过以下方式做了同样的事情:
WebKit.DOM.Document doc1 = webKitBrowser1.Document;
WebKit.DOM.NodeList tags = doc1.getElementsByTagName("input");
现在,我们可以使用索引值从 NodeList 标签访问每个标签,如:
WebKit.DOM.Element elm = (WebKit.DOM.Element)tags[index];
要在 VB 中采用上述方法,您只需更改变量类型。概念将保持不变。
也许您的大小写错误?尝试...
alert(document.getElementsByTagName("div"));
或 console.log(document.getElementsByTagName("div")) 如果您熟悉 Safari/Chrome 的 Web Inspector。