首页 > 解决方案 > 在没有任何 id 的 Pre Tag 中获取文本

问题描述

我正在做网页抓取,并想在 vba 中获取 Pre 标记内的文本。但不幸的是,pre 标签没有任何 id。有人可以指导我如何做到这一点

<form method="post" name="statusummary" action="/servstat" id="statserv">
<pre>
....
....
....

</pre>
</form>

标签: vbaweb-scraping

解决方案


尝试使用相邻的兄弟组合器将 id 与 pre 标记组合(假设您的缩进是正确的),即位置匹配

ie.document.querySelector("#statserv + pre")

推荐阅读