tasker should be capable of that. It can execute HTTP_GET commands, and it can also deal with data connections; but for the latter, depending on the Android version you're running on your device, you might need root access to toggle data connection.
Tasker uses (combinations of) "conditions" (also called "context") to trigger "tasks" – which both together is called a "profile". So you would need a profile for that. Let's go step-by-step:
Your condition will be a time-based one, as you want to check connectivity periodically. Chose wisely here: checking too often might become a battery-drain – checking to rarely makes the whole thing useless. Play starting with 1 minute, and maybe go down to 30s if that's not enough.
The task then is a conditional one, which could be described as "switch off WiFi if I cannot reach the internet". So let's put that together:
In the fields, define the time frame this should be active in, and the "repeat" interval.
- WiFi connected.
I recommend adding that to safe some juice: If you're already on mobile data with WiFi turned off, there's no need to turn WiFi off – right? Alternatively, you could also use
%WIFI ~ on – but that could give you a headache when you just switch it on and, failing to retrieve the URL, Tasker switches it off before it connects ;)
- HTTP Get
- WiFi (off) IF %HTTPR ~ -1
%HTTPR is a Tasker variable where the response code is stored into. According to the Tasker UserGuide, A response code of -1 indicates a problem making the request. This problem should be a timeout or "network unreachable" error (as a "not found" should be a "404" code), but you might need to play with this.
The above doesn't cover an "automatic return", so you had to enable WiFi manually (though that could be automated by a second "profile", periodically checking if things changed).