我需要从HTML标记下方提取“我要重试的消息”
<div id="m_7qo0yziAwqKk02Gud0IM" style="padding: 0px 0px 10px; width: 681px;" class="w-7qo0yziAwqKk02Gud0t9 moduleContent">
<div id="ext-comp-1345" class=" x-panel" style="width: 681px;">
<div class="x-panel-bwrap" id="ext-gen931">
<div class="x-panel-body x-panel-body-noheader x-column-layout-ct" id="ext-gen932" style="width: 681px;">
<div class="x-column-inner" id="ext-gen934" style="width: 681px;">
<div id="ext-comp-1346" class=" x-panel diff-area diff-enabled x-column" style="font-size: 23px; width: 591px;">
<div class="x-panel-bwrap" id="ext-gen936">
<div class="x-panel-body x-panel-body-noheader" id="ext-gen937" style="width: 591px;">message i've to retry</div>
</div>
</div>
<div id="ext-comp-1348" class=" x-panel x-column" style="padding: 4px 0px 4px 2px; font-size: 11px; color: rgb(160, 160, 160); width: 589px;">
</div>
</div>
</div>
</div>
</div>
</div>
我使用下面的VBA代码指向父标记,但不知道如何指定子标记来获取数据。
Dim IE As New InternetExplorer
Dim doc As HTMLDocument
Set doc = IE.document
IE.navigate "Site link"
Dim dd As Variant
dd = doc.getElementById("m_7qo0yziAwqKk02Gud0IM")
任何人都可以带领我
谢谢!
答案 0 :(得分:2)
我使用下面的代码来获取数据,
Dim finalout As Variant
Dim dd As HTMLObjectElement
Set dd = doc.getElementById("m_7qo0yziAwqKk02Gud0IM") 'assign web elements to a HTML document object
finalout = dd.getElementsByClassName(" x-panel x-column")(2).innerText 'now we have a bunch of required webtags in dd, out of which get your data by using methods and proper syntax
MsgBox finalout
它对我有用。 : - )