You do develop a good eye for wild camping sites and you also start to learn when it's probably going to be difficult, in which case, you make other back-up plans.
Wild camping is technically illegal in France (don't know about Spain) but as long as you're being quiet and respectful (not jumping fences, starting fires, trampling cultivated fields), the chances you get moved on are quite slim. I always figured the line: "But sir, I'm cycling around the world." would go a long way and anyway... a night in the police station sounds pretty luxurious by comparison. Might even get breakfast and a hot shower!