my blog is abt wht i have learnt technically, mostly in Ruby on Rails, Javascript, node.js hope this share a little bit of info & adds a bit stuff., Thanks.
Sunday, May 17, 2009
check whether an url is working or not..
1. For domains: ping "domain name"
2. For urls, use the following..
def check_valid_link(link_url)
retrycount = 0
begin
res = Net::HTTP.get_response(URI.parse(link_url))
if res.code =~ /2|3\d{2}/
return true
else
return false
end
rescue Timeout::Error
if retrycount < 4
retrycount += 1
sleep 3
retry
else
return false
end
rescue
return false
end
end
Labels:
rails,
ruby,
srikanth,
url,
url working,
valid link,
valid url
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment