0
我有一個網頁有多種形式。每個提交的表格都打開一個新頁面。我試圖從這些網頁中獲取數據。使用下面的代碼,我可以打開頁面,但數據從表單頁面拉出,而不是在提交後出現的頁面。多個表單提交併從結果頁面解析數據
我看了這個解決方案,但它不適用於我的情況。
excel vba form submit and parse data from result
這裏是我的代碼;
Set formsw = IE.document.forms
For Each form In formsw
For Each elem In form.elements
If elem.Value = "Show Summary (Html)" Then elem.Click
Do Until IE.ReadyState = 4: DoEvents: Loop
Do While IE.Busy: DoEvents: Loop
Sheet1.Activate
Sheet1.Cells.ClearContents
r = 0
For Each TRelement In IE.document.getElementsByTagName("TR")
Sheet1.Range("A1").Offset(r, 0).Value = TRelement.innerText
r = r + 1
Next
End If
Next
Next
Set form = Nothing
這裏是源代碼的一部分;
<input class="newInputButton" type="button" name="btnSubmit" width="100%" value="Show Summary (Html)" onclick="javascript:form1.action='/BEP/ShowApproved?w=0'; form1.target='_blank'; form1.submit();">
<input class="newInputButton" type="button" name="btnSubmit" width="100%" value=""Show Details (Html)" onclick="javascript: form1.action='/BEP/ShowApproved?w=0'; form1.target='_blank'; form1.submit();">
<input class="newInputButton" type="button" name="btnSubmit" width="100%" value="Show Summary (Html)" onclick="javascript:form2.action='/BEP/ShowApproved?w=0'; form2.target='_blank'; form2.submit();">
<input class="newInputButton" type="button" name="btnSubmit" width="100%" value=""Show Details (Html)" onclick="javascript: form2.action='/BEP/ShowApproved?w=0'; form2.target='_blank'; form2.submit();">
任何幫助表示感謝,謝謝!