1

我需要从 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")

谁能带领我

谢谢 !

4

1 回答 1

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

它对我有用。:-)

于 2013-01-25T11:48:18.070 回答