使 Web Scraper 操作从登录页面打开的弹出页面

Make Web Scraper manipulate a pop-up page that it opens from landing page

我的代码打开一个页面并开始完成它。然后它单击一个按钮,该按钮会弹出一个需要完成的屏幕。但是,我不确定如何让我的代码访问弹出屏幕。如有任何帮助,我们将不胜感激!

这是我的代码:

Sub Van()

Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")

IE.navigate ("website")

IE.Visible = True

Do
DoEvents
Loop Until IE.readystate = 4

Set d = IE.document

'Code clicks on buttons and dropdowns

Application.Wait (Now + TimeValue("00:00:03"))

d.GetElementbyid("caravanMake").Value = "JAY"


End Sub

这对我设置弹出窗口中第一个下拉菜单的值很有帮助:

'...
Application.Wait (Now + TimeValue("00:00:03"))

Set IE2 = GetIE("https://secure.apia.com.au/NASApp/apia/CRQuoteServlet?" & _
                 "pageAction=openModelSelectionWindow&currentSequenceNumber=")

IE2.document.getElementsByTagName("select")(0).Value = "JAY"
'etc

查找具有给定 URL 的开放 window 的函数:

'Find an IE window with a matching URL
'Assumes no frames.
Function GetIE(sAddress As String) As Object

Dim objShell As Object, objShellWindows As Object, o As Object
Dim retVal As Object, sURL As String


    Set retVal = Nothing
    Set objShell = CreateObject("Shell.Application")
    Set objShellWindows = objShell.Windows

 'see if IE is already open
    For Each o In objShellWindows
        sURL = ""
        On Error Resume Next
        sURL = o.LocationURL
        On Error GoTo 0
        If sURL <> "" Then
            'Debug.Print sURL
            If sURL = sAddress Then
              Set retVal = o
              Exit For
            End If
        End If
    Next o

Set GetIE = retVal
End Function