Skip to content

Instantly share code, notes, and snippets.

@BANKA2017
Last active March 14, 2019 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BANKA2017/91028c09415966457ba669cdcce29faf to your computer and use it in GitHub Desktop.
Save BANKA2017/91028c09415966457ba669cdcce29faf to your computer and use it in GitHub Desktop.
bing每日一图抓取脚本
<?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