This is the code for downloading files from internet.
In python (Local computer)
First install requests
pip install requests
import requests
image_url = input("Paste your file url : ")
saveAs = input("Save As : ")
r = requests.get(image_url)
print("\nDownloading Files...\n")
with open(saveAs, "wb") as foo:
foo.write(r.content)
print("\nFile has been saved\n")
In Google Colab
import requests
image_url = "https://example.com/file.png" # Paste file url here
r = requests.get(image_url)
print("\nDownloading Files...\n")
# Enter your file name ⬇⬇
with open("exampleFile.png", "wb") as foo:
foo.write(r.content)
print("\nFile has been saved\n")
For reference
import requests
image_url = input("Paste your file url : ")
saveAs = input("Save As : ")
r = requests.get(image_url)
print("\nDownloading Files...\n")
with open(saveAs, "wb") as foo:
foo.write(r.content)
print("\nFile has been saved\n")
'''
# In google colab
------------------------------------------
import requests
image_url = "https://example.com/file.png" # Paste file url here
r = requests.get(image_url)
print("\nDownloading Files...\n")
# Enter your file name ⬇⬇
with open("exampleFile.png", "wb") as foo:
foo.write(r.content)
print("\nFile has been saved\n")
'''
Writer ⮕ Junaid
Publisher ⮕ Junaid
Top comments (0)