我尝试了下面的代码。大部分时间跑步都卡在了后面on error goto 0
,没有成功.fireevent ("onchange")
。它可能是某种方式可以更好地优化流程。请帮帮我,谢谢。
Public Sub makeselections()
Dim ie As New InternetExplorer, var As String, ele As Object
var = ThisWorkbook.Worksheets("Sheet2").Cells(1, 1).value
With ie
.Visible = True
.Navigate2 "https://www.marketwatch.com/investing/stock/" & var & "/financials"
While .Busy Or .readyState < 4: DoEvents: Wend
With .document
.querySelector("#autocomplete_input").value = var
.querySelector("#investing_ac_button").Click
End With
While .Busy Or .readyState < 4: DoEvents: Wend
With .document
Do
On Error Resume Next
Set ele = .querySelector("[value^='/investing/stock/" & LCase(var) & "/financials/Income/quarter']")
On Error GoTo 0
Loop While ele Is Nothing
.querySelector("[value^='/investing/stock/" & LCase(var) & "/financials/Income/quarter']").Selected = True
.querySelector(".financials select").FireEvent "onchange"
End With
End With
End Sub