Download PDF using Python Requests

from pathlib import Path import requests filename = Path(‘myfile.pdf’) headers = {‘User-Agent’: ‘Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36’} url = ‘http://example.com/myfile.pdf’ response = requests.get(url, headers=headers) filename.write_bytes(response.content)