Skip to content

Instantly share code, notes, and snippets.

@BexTuychiev
Created July 14, 2020 09:29
Show Gist options
  • Save BexTuychiev/d5fa6ecddb5c1b1c30bc93aa977fbe57 to your computer and use it in GitHub Desktop.
Save BexTuychiev/d5fa6ecddb5c1b1c30bc93aa977fbe57 to your computer and use it in GitHub Desktop.
import requests
url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
def download(url):
# Send a request to the given url
response = requests.get(url, allow_redirects=True)
# Extract the file extension
extension = url.split('.')[-1]
# Save the file locally
with open(f'new_file.{extension}', 'wb') as file:
file.write(response.content)
download(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment