大家都知道微软的Bing搜索引擎首页每天都会提供了一些有趣的图片,而这些图片很多都是有故事含义的,很多网友每天去访问bing首页都是为了这些图片而去的,那么怎么下载下来呢。
获取API接口:
通过抓包,可以发现:
http://www.bing.com/HpImageArchive.aspx?format=xml&idx=0&n=1
这里可以获取到无水印的图片
通过模拟UA,访问移动版。同样发现了API接口
不过这里的图片是有水印的
代码:
<?php
/**
* 获取Bing每日壁纸 无水印
* @author myitmx
*/
$str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1');
if(preg_match("/<url>(.+?)<\/url>/ies",$str,$matches)){
$imgurl='http://cn.bing.com'.$matches[1];
}
if($imgurl){
header('Content-Type: image/JPEG');
@ob_end_clean();
@readfile($imgurl);
@flush(); @ob_flush();
exit();
}else{
exit('error');
}
?>
获取到的图片分辨率为:1366*768分辨率
效果:
图片地址:https://www.myitmx.com/bing/bing.php