Powershell gets HTML instead of PDF from PDF link

310 views Asked by At

I'm attempting to use Invoke-WebRequest to download a freely-available PDF. My URL points to a PDF, and the Get request made in-browser for my PDF points to my URL. I attempted

Invoke-WebRequest -uri "https://onlinelibrary.wiley.com/doi/pdf/10.1111/gec3.12537" -outfile "file.pdf"

And got HTML instead. I tried adding -MaximumRedirection 2 and still got HTML. Changing redirection to 0 or 1 only produced errors.

This seems to happen with every link I attempt at that web domain.

1

There are 1 answers

0
marsze On

It seems that url does not return the PDF per se, but a HTML age that most likely uses PDF.JS or a variatione thereof to display the document inside the browser.

I don't know the site, but it seems you already have found a way to download the actual PDF file directly yourself.