Last active
March 14, 2019 04:46
-
-
Save BANKA2017/91028c09415966457ba669cdcce29faf to your computer and use it in GitHub Desktop.
bing每日一图抓取脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ignore_user_abort(true); | |
$path=date('Ym'); | |
if(!file_exists(dirname(__FILE__).'/'.$path)){ | |
mkdir(dirname(__FILE__).'/'.$path,0777); | |
} | |
$pathurl = dirname(__FILE__).'/'.$path.'/'.date('d').'.jpg'; | |
if(!is_file($pathurl)){ | |
$str=json_decode(file_get_contents('https://cn.bing.com/HPImageArchive.aspx?idx=0&n=1&format=js'),1) | |
if(!empty($str["images"][0]["urlbase"])){ | |
$imgurl='http://cn.bing.com'.$str["images"][0]["url"]; | |
copy($imgurl,$pathurl); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment