How to automatically click the download button?

Jose Antonio Sanches Sanches 0 Reputation points
2023-06-03T13:13:14.0133333+00:00

How to download pdf file, which requires click botton?

Invoke-WebRequest -Uri “https://sbpcacervodigital.org.br/bitstream/20.500.11832/8353/1/BR_SPCMAIHSBPC_PUBLIC_JC_JC_431.pdf” -OutFile “D:\"

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,617 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,363 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,052 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Osjaetor 475 Reputation points
    2023-06-03T14:13:22.03+00:00

    Hi Jose Antonio,

     This script can help you:
    
    $url = "https://sbpcacervodigital.org.br/bitstream/20.500.11832/8353/1/BR_SPCMAIHSBPC_PUBLIC_JC_JC_431.pdf" 
    $response = Invoke-WebRequest -Uri $url 
    $buttonElement = $response.Forms[0].Fields[“ButtonID”] # You need replace “ButtonID” with the name or ID of the button 
    $response = Invoke-WebRequest -Uri ($response.Forms[0].Action) -Method $response.Forms[0].Method -Body $buttonElement 
    $response.Content | Set-Content -Path "D:\" -Encoding Byte
    

    Regards,

    0 comments No comments