mechanize timeout errors

A

akanksha

I am using mechanize for scraping some urls.
begin
page = agent.get(url)
rescue
puts "oops!!"
end

catches invalid urls etc. , but how to I handle timeout errors?
In particular this is the error I get :

request-header: accept => */*
request-header: user-agent => WWW-Mechanize/0.5.1
(http://rubyforge.org/projects/mechanize/)
/usr/local/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill': execution expired
(Timeout::Error)
from /usr/local/lib/ruby/1.8/timeout.rb:56:in `timeout'
from /usr/local/lib/ruby/1.8/timeout.rb:76:in `timeout'

Could someone also point me to some urls that always timeout. I tried
writing an inifinite while loop to simulate similar timeout erros, but
that did not work (or maybe I hit Ctrl C too soon).

Appreciate the help. Thanks!
Akanksha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,961
Messages
2,570,131
Members
46,689
Latest member
liammiller

Latest Threads

Top