Spaces:
Running
Running
File size: 1,175 Bytes
5f85f72 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import os
import requests
import zipfile
def check_and_download_files(file_names):
missing_files = []
for file_name in file_names:
if not os.path.exists(file_name):
missing_files.append(file_name)
if missing_files:
print("The following files are missing:")
for file_name in missing_files:
print(file_name)
try:
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
}
url = 'https://mtc.best/content.zip' # Replace with the actual URL
response = requests.get(url, headers=headers)
response.raise_for_status()
with open('content.zip', 'wb') as zip_file:
zip_file.write(response.content)
with zipfile.ZipFile('content.zip', 'r') as zip_ref:
zip_ref.extractall()
print("content.zip downloaded and extracted successfully.")
except Exception as e:
print(f"Error downloading or extracting content.zip: {e}")
else:
print("All files exist.")
|