import urllib.request import os images_dir = '/opt/ai-os/products/ceo/projects/blog/vwg-content/tai-sao-chon-viet-nam/images' os.makedirs(images_dir, exist_ok=True) images_map = { "dam-cuoi-diem-den-viet-nam-01.webp": "https://images.unsplash.com/photo-1519741497674-611481863552?w=1200&auto=format&fit=crop&q=80", "dam-cuoi-sa-pa-02.webp": "https://images.unsplash.com/photo-1528127269322-539801943592?w=1200&auto=format&fit=crop&q=80", "dam-cuoi-da-nang-hoi-an-03.webp": "https://images.unsplash.com/photo-1559592413-7cec4d0cae2b?w=1200&auto=format&fit=crop&q=80", "dam-cuoi-phu-quoc-04.webp": "https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=1200&auto=format&fit=crop&q=80", "dam-cuoi-tp-ho-chi-minh-05.webp": "https://images.unsplash.com/photo-1519167758481-83f550bb49b3?w=1200&auto=format&fit=crop&q=80", "lich-cuoi-theo-mua-viet-nam-06.webp": "https://images.unsplash.com/photo-1506744038136-46273834b3fb?w=1200&auto=format&fit=crop&q=80", "am-thuc-tiec-cuoi-viet-nam-07.webp": "https://images.unsplash.com/photo-1530103862676-de8c9debad1d?w=1200&auto=format&fit=crop&q=80", "may-do-vay-cuoi-viet-nam-08.webp": "https://images.unsplash.com/photo-1594552072238-b8a33785b261?w=1200&auto=format&fit=crop&q=80", "dam-cuoi-diem-den-viet-nam-09.webp": "https://images.unsplash.com/photo-1583939003579-730e3918a45a?w=1200&auto=format&fit=crop&q=80" } headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36' } for filename, url in images_map.items(): filepath = os.path.join(images_dir, filename) print(f"Downloading {filename}...") try: req = urllib.request.Request(url, headers=headers) with urllib.request.urlopen(req, timeout=30) as response, open(filepath, 'wb') as out_file: out_file.write(response.read()) print(f" OK -> {os.path.getsize(filepath)} bytes") except Exception as e: print(f" ERROR: {e}") print("All downloads finished!")