smart-interactive-display/Assets/StreamingAssets/MergeFace/test.py

21 lines
582 B
Python

import requests
import os
image_url = "https://i.ibb.co/8Xw8Yhs/4c91e57ac0340d5eaf137cfc48ecb8bc-1557153402.jpg"
file_name = "downloaded_image.jpg"
# Check if the file already exists
if not os.path.exists(file_name):
# Send a GET request to the URL
response = requests.get(image_url)
# Open a local file with write-binary mode
with open(file_name, "wb") as file:
# Write the contents of the response to the file
file.write(response.content)
print(f"Image downloaded and saved as {file_name}")
else:
print(f"{file_name} already exists.")