我有一个正在从中提取数据的网页。除了单击图像元素然后提交表单并创建包含数据的弹出窗口之外,我可以使用 VBA 完成所有操作。
图像元素中的属性之一称为“productguid”,并且具有字符串值 =
“a12-545”。
在我用鼠标单击图像元素之前,表单的 HTML 代码如下所示。
<form id="GetProductQuantitiesForAccessibleBranches" action="GetProductQuantitiesForAccessibleBranches" method="post">
<input type="hidden" name="ProductGuid" value="">
</form>
这是我用鼠标手动单击后的 HTML 代码:
<form id="GetProductQuantitiesForAccessibleBranches" action="GetProductQuantitiesForAccessibleBranches" method="post">
<input type="hidden" name="ProductGuid" value="a12-545">
</form>
基于此,我假设图像元素中的productguid 值在提交之前已传递到表单上。
我的 VBA 代码如下所示:
'Change the input element value
ie.Document.getElementById("GetProductQuantitiesForAccessibleBranches").all.item(0).value = "a12-545"
'Submit the form
ie.Document.getElementyId("GetProductQuantitiesForAccessibleBranches").Submit
根据 Locals 窗口,所有 Javascript 事件都是Null
。两行代码运行都没有任何错误,但网页没有更新。我在这里错过了什么吗?
我也尝试过仅单击图像元素.Click
方法,但这也没有任何作用。
该网页受密码保护,因此我无法公开发布该 URL。
UPDATE:
以下是通常手动单击的标记中的 HTML,然后提交表单。也许这里有一些我可以使用的东西?
<img alt="View Quantities At Other Locations" src="/WebOrder/Images/CheckQtys.gif"
title="View Quantities At Other Locations" class="popup"
popupdirection="upperleft" popupwidth="380"
popupcontent="#ProductQuantitiesForAccessibleBranches"
onbeforepopupcreate="onBeforePopupCreate_GetProductQuantitiesForAccessibleBranches(this)"
popupajaxformid="GetProductQuantitiesForAccessibleBranches"
onbeforepopupajaxpost="onBeforePopupAjaxPost_GetProductQuantitiesForAccessibleBranches(this)"
oncompletepopupajaxpost="onCompletePopupAjaxPost_GetProductQuantitiesForAccessibleBranches(this)"
productguid="a12-545"
displayitem="33902"
brandguid="00000000-0000-0000-0000-000000000000"
brandname="" brandsku="">