-3

I currently need to download multiple PDF files from a specific website.

Once I reach to this point the usual action is to click on the save button or to type "CTRL + S"

Click on Save button

I retrieved this on this post of IE Automation

But I'm trying to excecute the download action with the following code:

bot.SendKeys Keys.Control, "s"

And is not working.

How can I make this work on Chrome?

Thanks,

2 Answers2

0

You could use this to download the pdfs.

   Dim PDF_URL as string

   #If VBA7 Then
    Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" ( _
    ByVal pCaller As LongPtr, _
    ByVal szURL As String, _
    ByVal szFileName As String, _
    ByVal dwReserved As LongPtr, _
    ByVal lpfnCB As LongPtr) As LongPtr

#Else
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" ( _
ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
#End If



Private Sub File_Download()
    Dim FileURL As String
    Dim DestinationFile As String
    FileURL = PDF_URL
    DestinationFile = "C:\PDFs\PDFName.pdf"
    If URLDownloadToFile(0, FileURL, DestinationFile, 0, 0) = 0 Then
        Debug.Print "File downloaded started"
    Else
        Debug.Print "File downloaded not started"
    End If
End Sub


Private Sub GetURL
  PDF_URL = Chrome_Driver.FindElementById("EleID").Attribute("src")
  File_Download
end sub
KNAPPYFLASH
  • 141
  • 1
  • 5
0

There are a ton of websites that may not allow bots. You should go to the website's /robots.txt to see if there are any restrictions on bots pulling the content you are trying to grab. These sections will show "disallow" anything bots are forbidden to access.

example: google/robots.txt

Yes, websites can even tell if you are using Selenium.