How to automatically fetch images from a website and update desktop image to match (in terminal)?
You have a couple of options to tackle this:  AppleScript and a Bash (Terminal) script.  Since this needs to happen once per day (meaning scheduled) and you want to guarantee that the file gets downloaded the moment you're logged in so it can be there when you start and then once again every night at midnight,  I would do this in Bash.

Create the Script

The script is going to do two things:


Download the image
Set as the background image


The script is fairly simple.  It takes two arguments - URL and the location to save the file.  It will then download it to that folder location:

#!/bin/bash
#Bash Script to Download Forecast and Set as desktop background

#User Defined VARs below:

#URL to fetch image 
url="http://www.cleardarksky.com/c/YerkesObILcsk.gif?c=2239204"

#Picture file Location
picFile="/Users/Thomas/Pictures/test.gif"


#Command to retrieve picture and save to defined location
curl -o "${picFile}" "$url"

exit


Save it in a convenient location; give it an obvious name like getSkyForecast.sh.  Make sure to make the script executable - chmod +x getSkyForecast.sh  If you don't do this, the script won't run.

Schedule the Script

The following is a bit more complex, because it will run upon login and every 24 hours. 

Next, the script needs to be kicked off with launchd.  To do this, you need a plist (XML file that describes the job)

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;com.user.getSkyForecast&lt;/string&gt;
  &lt;key&gt;ProgramArguments&lt;/key&gt;
  &lt;array&gt;
      &lt;string&gt;/Users/USERNAME/Path_to_Scripts/getSkyForecast.sh&lt;/string&gt;
  &lt;key&gt;RunAtLoad&lt;/key&gt; 
  &lt;true/&gt;
  &lt;/array&gt;
  &lt;key&gt;StartCalendarInterval&lt;/key&gt;
  &lt;array&gt;
  &lt;dict&gt;
    &lt;key&gt;Hour&lt;/key&gt;
    &lt;integer&gt;00&lt;/integer&gt;
    &lt;key&gt;Minute&lt;/key&gt;
    &lt;integer&gt;00&lt;/integer&gt;
  &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Save this file as com.user.SkyForecast and copy it to the ~/Library/LaunchAgents directory.

Load it with the command:

launchctl load com.user.SkyForecast


Set the background image

The easiest thing to do is just go into System Preferences and set the Background image to this file (run the script manually first so it creates the file).  When the script runs, it will change the file, not the name so the desktop image will change automatically.