Created
July 14, 2020 09:29
-
-
Save BexTuychiev/d5fa6ecddb5c1b1c30bc93aa977fbe57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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