From: "Jesús Gabriel y Galán" Date: 2011-05-04T17:13:48+09:00 Subject: Re: Check url address On Wed, May 4, 2011 at 9:50 AM, Lukáš N. wrote: > Hello all, > > i would like to do something like define two urls, primary and > secondary. After that, check them and if primary is not available, > choose secondary url. At the end, put these to some variable for next > usage. You can try to open the first URL and if there's any exception, use the second one. Something like: ruby-1.9.1-p431 :004 > require 'open-uri' => true ruby-1.9.1-p431 :005 > url1 = "http://fsdfsdfsdf.com" => "http://fsdfsdfsdf.com" ruby-1.9.1-p431 :006 > url2 = "http://www.google.com" => "http://www.google.com" ruby-1.9.1-p431 :007 > valid_url = begin ruby-1.9.1-p431 :008 > open(url1) ruby-1.9.1-p431 :009?> url1 ruby-1.9.1-p431 :010?> rescue ruby-1.9.1-p431 :011?> url2 ruby-1.9.1-p431 :012?> end => "http://www.google.com" ruby-1.9.1-p431 :013 > valid_url => "http://www.google.com" Jesus.