From: Robert Klemme Date: 2010-07-20T16:16:23+09:00 Subject: Re: how to judge web exists or not with open-uri? 2010/7/20 Pen Ttt : > 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"} You better use Net::HTTP for this http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/index.html url = URI.parse('www.123.com') status = Net::HTTP.start(url.host, url.port) {|http| http.head(url.path) } puts( /^2/ =~ status.code ? "ok" : "nok" ) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/