Q:

File corrupted when I try to download via requests.get()

I'm trying to automate the download of docs via Selenium. 
I'm using requests.get() to download the file after extracting the url from the website:
import requests 

url= 'https://www.schroders.com/hkrprewrite/retail/en/attach.aspx?fileid=e47b0366c44e4f33b04c20b8b6878aa7.pdf'
myfile = requests.get(url)
open('/Users/hemanthj/Downloads/AB Test/' + "A-Acc-USD" + '.pdf', 'wb').write(myfile.content)
time.sleep(3)

The file is downloaded but is corrupted when I try to open. The file size is only a few KB at most. 
I tried adding the header info from this thread too but no luck:
Corrupted PDF file after requests.get() with Python
What within the headers makes the download work? Any solutions?

A:

The problem was in an incorrect URL. 
It loaded HTML instead of PDF.
Looking throw the site I found the URL that you were looking for.
Try this code and then open the document with pdf reader program.

import requests
import pathlib

def load_pdf_from(url:str, filename:pathlib.Path) -> None:
    response:requests.Response = requests.get(url, stream=True)
    if response.status_code == 200:
        with open(filename, 'wb') as pdf_file:
            for chunk in response.iter_content(chunk_size=1024):
                pdf_file.write(chunk)
    else:
        print(f"Failed to load pdf: {url}")

url:str = 'https://www.schroders.com/hkrprewrite/retail/en/attachment2.aspx?fileid=e47b0366c44e4f33b04c20b8b6878aa7.pdf'

target_filename:pathlib.Path = pathlib.Path.cwd().joinpath('loaded_pdf.pdf')

load_pdf_from(url, target_filename)

