Пример скрипта (использовал выше), который будет скачивать файлы в директорию с ним же, по заданным Вами прямим ссылкам.
import os
import sys
import requests
from tqdm import tqdm
def download_file(url, filepath):
try:
response = requests.get(url, stream=True)
response.raise_for_status()
total_size = int(response.headers.get('content-length', 0))
with open(filepath, 'wb') as file, tqdm(
total=total_size, unit='B', unit_scale=True, desc=f"Скачивание {os.path.basename(filepath)}"
) as progress_bar:
for chunk in response.iter_content(chunk_size=8192):
file.write(chunk)
progress_bar.update(len(chunk))
except Exception as e:
print(f"Ошибка при скачивании {os.path.basename(filepath)}: {e}")
if __name__ == "__main__":
urls = [
("YourLink1"),
("YourLink2"),
]
current_dir = os.path.dirname(sys.executable if getattr(sys, 'frozen', False) else __file__)
for url, filename in urls:
download_file(url, os.path.join(current_dir, filename))