簡體   English   中英

VBA 自動化的 Internet Explorer 替代品

[英]Internet Explorer alternative for VBA automation

我有一個 VBA 代碼來瀏覽網頁、閱讀內容、單擊按鈕、填寫文本等...此代碼使用 Internet Explorer。 下面我沒有復制代碼,只是把我使用的主要對象給你一個想法:

Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Dim oHTML_Element As IHTMLElement


Set ie = CreateObject("InternetExplorer.Application")
ie.navigate Url
ie.Visible = True

...

Set oBrowser = ie
oBrowser.Visible = True

...    
Set HTMLDoc = oBrowser.document

Set nodeAllDiv = HTMLDoc.getElementsByTagName("p")

Txt = nodeAllDiv.Item(0).innerText

..

HTMLDoc.getElementsByTagName("p").Item(nodeAllDiv.Length - 1).Click

Set listButtons = HTMLDoc.getElementsByTagName("button")
listButtons.Item(0).Click


Set formDivs = HTMLDoc.getElementsByTagName("form")

問題是最近我正在導航的網頁不再受 Internet Explorer 支持,而是使用 Chrome 或 Edge,因此我不能按原樣使用這個 VBA 代碼。

有沒有辦法可以重用我迄今為止寫的東西(重用相同的對象等......)? 如果可能,無需遷移到另一種框架/語言

謝謝

Seleniumbasic是 VBA 環境的 web 自動化 package,您可能想看看。

Seleniumbasic 的 Github 回購

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM