我可以成功获得<table class="specs" ng-hide="false">
和<table class="specs ng-hide" ng-hide="true">
的<td>
标签的Innertext:
Set CHRA = aIE.document.getElementsByClassName("specs")(4).getElementsByTagName("td")
For Each Item In CHRA
Debug.Print Item.innertext
Next
这些真实的HTML来自不同的URL,其中一个表被隐藏,另一个表可见。对于TRUE,输出是CHRA
和779543-0027
,对于False ON,输出为CHRA
和715214-0011
:
我不想获得错误属性的结果。有什么办法可以绕过这个?
这是HTML代码的其余部分(True版本是完全相同的,除了第一部分是<table class="specs ng-hide" ng-hide="true">
:
<table class="specs" ng-hide="false">
<thead>
<tr>
<th colspan="2">BOM Info</th>
</tr>
</thead>
<tbody>
<tr>
<td>CHRA</td>
<td><span class="ng-binding">715214-0011</span> <input type="checkbox" ng-hide="bom.strChra[0]==undefined" id="cpbchra" class="combuy" value="715214-0011" style="display: none;"></td>
</tr>
</tbody>
</table>
我找到了解决方案,以防您有兴趣:
Set CHRA1 = aIE.document.getElementsByClassName("specs ng-hide")(0).getElementsByTagName("td")
Set CHRA2 = aIE.document.getElementsByClassName("specs")(4).getElementsByTagName("td")
If CHRA1(1).innertext <> CHRA2(1).innertext Then
Debug.Print CHRA2(1).innertext
End If