接着上一篇吧~

搜着搜着,也想起来有一个必应每日壁纸呀 艸
必应每天都会更新一张当日壁纸,也是不错的啊,虽然风景动物照为主哈。。。

开整~

文章末尾也有提供一个搭建好的咯~

1、新建网站(暂且命名 https://www.baidu.com

2、根目录新建一个文件(暂且命名为 bg.php),写入以下代码:

<?php
$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1');   // 从bing获取数据
 
if(preg_match('/<url>([^<]+)<\/url>/isU', $str, $matches)) { // 正则匹配抓取图片url
    $imgurl = 'http://cn.bing.com'.$matches[1];
} else {  // 如果由于某些原因,没抓取到图片地址
    $imgurl = 'http://img.infinitynewtab.com/InfinityWallpaper/2_14.jpg'; // 使用默认的图像(默认图像链接可修改为自己的)
}
 
header("Location: {$imgurl}");    // 跳转至目标图像

3、使用
跟正常使用一样,只需要将背景图片地址设置为 bg.php 文件的绝对路径,
比如这里就设置成 https://www.baidu.com/bg.php 即可!
如果你的 bg.php 文件放在网站的 img 文件夹中,那么就是 https://www.baidu.com/img/bg.php

(o゜▽゜)o☆[BINGO!]

已有 3 条评论

  1. 比如现在的评论框背景就是一个~

  2. 就很棒,马上去搞了一个

添加新评论