🌍 动态地球壁纸

📋 功能说明
  • 自动更换地球壁纸
  • 每日更新高清地球照片
  • 设为桌面背景
💻 源代码
import requests
import ctypes
import os
import time

def download_earth_image():
    """下载地球图片"""
    # NASA Earth API
    url = 'https://epic.gsfc.nasa.gov/api/natural'
    response = requests.get(url).json()
    
    if response:
        image_name = response[0]['image']
        date = response[0]['date']
        image_url = f'https://epic.gsfc.nasa.gov/archive/natural/{date.replace("-", "/")}/png/{image_name}.png'
        
        response = requests.get(image_url)
        with open('earth.png', 'wb') as f:
            f.write(response.content)
        return 'earth.png'
    return None

def set_wallpaper(image_path):
    """设置壁纸 (Windows)"""
    ctypes.windll.user32.SystemParametersInfoW(20, 0, image_path, 0)
    print(f"壁纸已设置为: {image_path}")

def auto_update(interval=3600):
    """自动更新壁纸"""
    while True:
        img = download_earth_image()
        if img:
            set_wallpaper(img)
        time.sleep(interval)

if __name__ == '__main__':
    img = download_earth_image()
    if img:
        set_wallpaper(img)
📦 运行环境
pip install requests
功能特点
  • ✅ NASA真实地球照片
  • ✅ 自动更换
  • ✅ Windows支持