I though of a random python program to take a URL and download the photo, then making it the Desktop background. People have had success with this before, but as of the macOS Sierra update I've been unable to do this. I've tried multiple ways, including those listed in this thread to no avail.
Does anyone know what Apple has changed their Desktop picture system to now? It's a tad frustrating when that's the only thing you set out to achieve and it's no longer the method people use.
How about if you setup your preferences to use a photo from a folder. Then your script can just drop the picture into that folder and the system will pick it up.
If you set your preferences to switch every 5 seconds, then you can change out that image whenever you script wants, and it'll be picked up within 5 seconds.
Just did a quick test moving images in and out and it works.