html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文档标题</title>
</head>
<body id="bg-shuaxin">
  

</body>
</html>

css

body {
  background-image: url('https://t.mwm.moe/pc');
  background-size: cover;
  background-repeat: no-repeat;
}

JavaScript

  function updateBackgroundImage() {
            const imageUrl = 'https://xn--xu0a.cn/api/dn';//图片URL
            const timestamp = Date.now();
            const section = document.getElementById('bg-shuaxin');//输入定义的ID
            section.style.backgroundImage = `url('${imageUrl}?${timestamp}')`;
            setTimeout(updateBackgroundImage, 5000); // 每5秒刷新一次
        }
        updateBackgroundImage(); // 初始化时立即执行一次