Similar to Download images from website
I'd like to download a list of images from a website where the url is having -number at the end. I was thinking of a simple loop that counts up like
#!/bin/bash
baseurl=https://www.theguardian.com/global-development-professionals-network/gallery/2016/dec/23/prayer-around-the-world-in-pictures-religion#img-
for (( c=1; c<=5; c++ ))
do
wget $baseurl-$c
done
But how can I break out of the loop when there is no valid picture any more?