Skip to content

Instantly share code, notes, and snippets.

@alexhanh
Created December 4, 2011 14:34
Show Gist options
  • Select an option

  • Save alexhanh/1430335 to your computer and use it in GitHub Desktop.

Select an option

Save alexhanh/1430335 to your computer and use it in GitHub Desktop.
def fetch
data = {}
begin
io = open(URI.encode(@baseurl))
doc = Nokogiri::HTML(io)
io.close!
# ... process doc ...
end
rescue Errno::ETIMEDOUT
return nil
rescue Errno::ECONNREFUSED
return nil
rescue SocketError
return nil
rescue Timeout::Error
return nil
rescue Errno::ECONNRESET
return nil
rescue EOFError
return nil
rescue OpenURI::HTTPError => e
return nil if e.io.status[0].to_s != "404"
data['name_changed'] = true
end
data
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment