我有一个网页,需要从中提取数据。我可以使用VBA做到除了点击图像元素外的所有操作,而点击图像元素会提交表单并创建一个带有数据的弹出窗口。
其中,图片元素中的一个属性名为“productguid”,其字符串值为“a12-545”。
在我用鼠标点击图像元素之前,表单的HTML代码如下。
根据“本地窗口”,所有Javascript事件均为“Null”。这两行代码都可以正常运行,但网页没有更新。我是否遗漏了什么?
我也尝试使用“.Click”方法仅单击图像元素,但那也没有任何作用。
该网页受密码保护,因此我无法公开发布URL。
更新:以下是通常手动点击以提交表单的标记中的HTML。也许我可以从中找到一些有用的内容?
其中,图片元素中的一个属性名为“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
根据“本地窗口”,所有Javascript事件均为“Null”。这两行代码都可以正常运行,但网页没有更新。我是否遗漏了什么?
我也尝试使用“.Click”方法仅单击图像元素,但那也没有任何作用。
该网页受密码保护,因此我无法公开发布URL。
更新:以下是通常手动点击以提交表单的标记中的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="">
ie.Document.getElementById("GetProductQuantitiesForAccessibleBranches").getElementsbyName("ProductGuid")(0).Value=Whatever
。 - Ryan Wildryie.Document.Forms("GetProductQuantitiesForAccessibleBranches").Submit
。 - Ryan Wildry