I am looking to automate the downloading of multiple PDFs from our corporate website. This site only works over our internal corporate network/VPN and requires authentication (and is also https only).
I've looked into logging in via VBA/python but have had troubles. I imagine due to some combination of our corporate network set up and restrictions on accessing the site.
I think the easiest thing would be to just use an existing browser session to download the files, rather than worry about all the authentication and network issues?
I adapted VBA code I found online to identify and set a variable to an existing, authenticated IE window and navigate to a PDF on our corporate website (see below).
From there, how can I automatically save the PDF page from the existing browser session? The couple ways I saw online for saving files in IE dont seem to work. If this is easier through python I am also open to that. Thanks!
marker = 0
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For x = 0 To (IE_count - 1)
On Error Resume Next ' sometimes more web pages are counted than are open
my_url = objShell.Windows(x).Document.Location
my_title = objShell.Windows(x).Document.Title
If my_title Like "XYZ" & "*" Then 'compare to find if the desired web page is already open
Set ie = objShell.Windows(x)
marker = 1
Exit For
Else
End If
Next
If marker = 0 then
msgbox("A matching webpage was NOT found")
Else
msgbox("A matching webpage was found")
ie.navigate("https://corpwebsite.com/abcdef.pdf")
End If