From: "Joseph E. Savard" Date: 2010-07-20T21:32:12+09:00 Subject: Re: how to judge web exists or not with open-uri? irb(main):017:0> def getURL(u) irb(main):018:1> begin irb(main):019:2* x = open(u) irb(main):020:2> rescue irb(main):021:2> puts "url does not exist" irb(main):022:2> end irb(main):023:1> end => nil irb(main):025:0> getURL("http://www.awqes.com") url does not exist => nil irb(main):026:0> getURL("http://www.google.com") => # irb(main):027:0> Not the string "url does not exist" is for visual confirmation. Though the x is returned as nil on a non-existent URL. ` > From: Pen Ttt > Reply-To: > Newsgroups: comp.lang.ruby > Date: Tue, 20 Jul 2010 14:00:57 +0900 > To: ruby-talk ML > Subject: how to judge web exists or not with open-uri? > > would you mind to tell me how to fix it, to make the following program > to run? > require 'rubygems' > require 'open-uri' > url="www.123.com" > open(url){|file| if url don't exists then puts "url don't exists" > else puts "url exists"} > thiks > -- > Posted via http://www.ruby-forum.com/. >