Daily new wallpapers

In the past I was able to get every day a new wallpaper from National Geo.
Unfortunately Bing and Ng coded that stuff so it’s not easy to fetch the data to download. The code below was tweaked but not written by myself. I’d give credits but it’s long time ago, so I can’t remember anymore the original source :frowning:

set WallPaper to POSIX path of (path to temporary items folder from user domain as text)
set cmd to "#!/bin/sh\ncd " & WallPaper & ";\ncurl http://photography.nationalgeographic.com/photography/photo-of-the-day/ -o pod\n# look for wallpaper version\nif (curl `cat pod | tr '\"' '\n' |grep -B 1  'Download wallpaper' | head -1` -o pod2) then\n\tcat pod2 | tr '\"' '\n' |grep -oh 'http://.*exposure.*.jpg' |head -1 | sed 's/0_360x270/0_1440x900/'\n\ta=`cat pod2 | tr '\"' '\n' |grep -B 4 -A 4 'Desktop Wallpaper' | grep '.jpg' | sed 's/0_1600x1200/0_1440x900/'`\n\tcurl 'http://photography.nationalgeographic.com/'$a -o national-geographic-photo-of-the-day.jpg;\nelse\n\t# download the image from here --- in case it is not a wallpaper\n\ta=`cat pod|tr '\"' '\n' |grep -A 20 \"primary_photo\"|grep nationalgeographic.com`\n\tcurl 'http:'$a  -o national-geographic-photo-of-the-day.jpg;\nfi\n"

That first URL returns a page saying that the URL has changed permanently to “http://www.nationalgeographic.com/photography/photo-of-the-day/” (ie. “www” instead of "photography.) The new URL opens in my browser, but doesn’t send anything when curl-ed in that way.

I’m not sure how your script works, but maybe you can repair it with the below code:

curl -L http://www.nationalgeographic.com/photography/photo-of-the-day | grep '<meta property=\"og:image\" content='|awk '{print $3}'| awk -F'\"' '$0=$2'

If that doesn’t work, this will download the photo and store it in the Downloads folder.

set pictureURL to do shell script "curl -L http://www.nationalgeographic.com/photography/photo-of-the-day| grep '<meta property=\"og:image\" content='|awk '{print $3}'| awk -F'\"' '$0=$2'"
do shell script "curl " & pictureURL & " -o ~/Downloads/photo-of-the-day.jpg"

In both snippets you must remove [ url ] and [ /url ] to get it to work in the Applescript editor.

Francv, I appreciate your thought.
Just as said before, both websites wrapped their daily pictures around a code, so a normal Curl doesn’t work. I mean, of course you can try but all you get will be an empty file. Anyway.
Merry Christmas!

I know, but my code does find the link Curl can use to download the Photo of the day.

In my previous message this forum has added additional tags to my code, so both code snippets don’t work. The curl command is (one line):

curl -L ‘http://www.nationalgeographic.com/photography/photo-of-the-day’|grep
‘<meta property="og:image" content=’|awk ‘{print $3}’| awk -F’"’ ‘$0=$2’

This also changed the link in the code:
Copy the correct link to be used from here