html - Download image with changing name daily -


i script downloads latest picture nasa's "astronomy picture of day" website use daily changing background. whilst picture description displayed on https://apod.nasa.gov/apod/astropix.html or iterative number in archive, images named incosistently. e.g. today's image located in <img src="image/1611/nhq201611140001_900x1238.jpg"...> whereas yesterday's picture found in <img src="image/1611/heartsoul_lindemann_960.jpg">

i found on how set image background automatically, don't know how proceed download.

with file_get_contents(), , mix of preg_match() can image want.

<?php      $data               = file_get_contents("https://apod.nasa.gov/apod/astropix.html");     $images             = preg_match("#(<img src=\")(.*?)(\".+>)#is", $data, $matches);     $imageoftheday      = null;     if(sizeof($matches) > 2){         $imageoftheday  = "https://apod.nasa.gov/apod/" . $matches[2];     }     echo $imageoftheday; 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -