试图提取数据

时间:2017-04-10 12:42:19

标签: html excel vba

我正在使用VBA并从页面中提取数据。我设法用"提取了大量数据。 oIE.document.body.innerHTML"

但是我遇到了这个innerHTML中没有页面上可见数据的东西。当我在页面上检查确切的位置时,我发现了它。屏幕截图下方。是否可以使用VBA提取此类数据?我感兴趣的是标记为蓝色的数据,正是这个有效的数字。

截图

Code

确定。

我正在使用

从公司页面中提取数据
                link = "Page" 

                oIE.navigate link
                Do Until Not oIE.Busy And oIE.readyState = READYSTATE_COMPLETE: Loop
                HTMLsource = UCase(oIE.document.body.innerHTML)

然后我使用SPLIT函数来获取我需要的数据。 但是在我最新的项目中,我遇到的数据在网站上是可见的,但不在我用innerHTML方法得到的字符串中。 我在innerHTML方法之后得到的字符串:

> <div id="mx_divTree"><div id="mx_divTreeHead"><table
> id="treeHeadTable"><tr class="mx_hidden-row"><td id="ROW_1"
> width="200"></td><td width="2"></td></tr><tr><th
> id="Name"><table><tr><td height="25"><input
> onclick="setCheckboxStatus(this)" name="chkList" class="small"
> type="checkbox"></input></td><td id="Name" class="mx_sort-column"><a
> href="javascript:sortTable(1)">Name</a></td><td
> id="Name_sort"></td><td id="Name_filter"></td></tr></table></th><th
> class="mx_sizer"></th></tr></table></div><div
> id="mx_divTreeBody"><table><col class="mx_tree"></col></table>

然而,当我用&#34检查页面时,检查元素&#34;在Mozzila中我发现上面的String缺少我需要的数据。但它在Inspect Element中可见。

<table xmlns="http://www.w3.org/1999/xhtml" id="treeBodyTable" data-drag="Name" width="239"><tbody><tr class="mx_hidden-row"><td position="-1" width="1"></td><td id="ROW_1" width="238"></td></tr><tr id="0,0" o="20336.41905.55555.59004" r="" class="root-node 
                    even
                " style="height: 35px;" height="35"><td class="" position="-1"></td><td position="1" rownumber="1" rmbid="20336.41905.55555.59004" rmbrow="0,0" draggable="true"><div id="0,0" o="20336.41905.55555.59004" r="" t="" draggable="false"><table draggable="false"><tbody draggable="false"><tr id="0,0" o="20336.41905.55555.59004" r="" draggable="false"><td draggable="false"><input name="emxTableRowIdActual" class="small" id="rmbrow-0,0" value="|20336.41905.55555.59004||0,0" onclick="doFreezePaneCheckboxClick(this, event); doCheckSelectAll();" draggable="false" type="checkbox"></td><td id="icon_0,0" draggable="false"><a href="javascript:;" draggable="false"><img src="images/iconSmallPart.png" draggable="false"></a>
                                    &nbsp;
                                </td><td title="80275509" position="1" rmbid="20336.41905.55555.59004" rmbrow="0,0" draggable="false" valign="middle"><a href="javascript:link(&quot;1&quot;,&quot;20336.41905.55555.59004&quot;,&quot;&quot;,&quot;&quot;,&quot;80275509&quot;)" data-oid="20336.41905.55555.59004" data-icon="images/iconSmallPart.png" class="object" draggable="false">80275509</a></td></tr></tbody></table></div></td></tr><tr id="0,1" o="20336.41905.60930.27530" r="" class="root-node 
                    mx_altRow
                " style="height: 35px;" height="35"><td class="" position="-1"></td><td position="1" rownumber="1" rmbid="20336.41905.60930.27530" rmbrow="0,1" draggable="true"><div id="0,1" o="20336.41905.60930.27530" r="" t="" draggable="false"><table draggable="false"><tbody draggable="false"><tr id="0,1" o="20336.41905.60930.27530" r="" draggable="false"><td draggable="false"><input name="emxTableRowIdActual" class="small" id="rmbrow-0,1" value="|20336.41905.60930.27530||0,1" onclick="doFreezePaneCheckboxClick(this, event); doCheckSelectAll();" draggable="false" type="checkbox"></td><td id="icon_0,1" draggable="false"><a href="javascript:;" draggable="false"><img src="images/iconSmallPart.png" draggable="false"></a>
                                    &nbsp;
                                </td><td title="80275509" position="1" rmbid="20336.41905.60930.27530" rmbrow="0,1" draggable="false" valign="middle"><a href="javascript:link(&quot;1&quot;,&quot;20336.41905.60930.27530&quot;,&quot;&quot;,&quot;&quot;,&quot;80275509&quot;)" data-oid="20336.41905.60930.27530" data-icon="images/iconSmallPart.png" class="object" draggable="false">80275509</a></td></tr></tbody></table></div></td></tr><tr id="0,2" o="20336.41905.2564.37500" r="" class="root-node 
                    even
                " style="height: 33px;" height="33"><td class="" position="-1"></td><td position="1" rownumber="1" rmbid="20336.41905.2564.37500" rmbrow="0,2" draggable="true"><div id="0,2" o="20336.41905.2564.37500" r="" t="" draggable="false"><table draggable="false"><tbody draggable="false"><tr id="0,2" o="20336.41905.2564.37500" r="" draggable="false"><td draggable="false"><input name="emxTableRowIdActual" class="small" id="rmbrow-0,2" value="|20336.41905.2564.37500||0,2" onclick="doFreezePaneCheckboxClick(this, event); doCheckSelectAll();" draggable="false" type="checkbox"></td><td id="icon_0,2" draggable="false"><a href="javascript:;" draggable="false"><img src="images/fpc.gif" draggable="false"></a>
                                    &nbsp;
                                </td><td title="80275509" position="1" rmbid="20336.41905.2564.37500" rmbrow="0,2" draggable="false" valign="middle"><a href="javascript:link(&quot;1&quot;,&quot;20336.41905.2564.37500&quot;,&quot;&quot;,&quot;&quot;,&quot;80275509&quot;)" data-oid="20336.41905.2564.37500" data-icon="images/fpc.gif" class="object" draggable="false">80275509</a></td></tr></tbody></table></div></td></tr></tbody></table>

所以我的问题是:这是否可以提取这个&#34;隐藏&#34;数据与VBA?

1 个答案:

答案 0 :(得分:0)

你应该能看到这个......

Set elements = doc.getElementsByid("0,0")
debug.Print = elements.innerHTML

elements声明为object应该给你这个(是吗?)

编辑(包括图书馆):

enter image description here