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

Comments

Popular posts from this blog

Install Cpanm module error : No such file or directory opening compressed index

How to increase Elasticsearch Shard recovery Speed

Getting started with Python Flask application with MVC structure