Created
December 4, 2011 15:24
-
-
Save alexhanh/1430449 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def better_fetch | |
| data = {} | |
| io = nil | |
| begin | |
| io = open(...) | |
| rescue OpenURI::HTTPError => e | |
| # Handle interesting http errors | |
| rescue Timeout::Error, StandardError | |
| # It was most likely a Net/Socket error we are not interested in, so just fail. | |
| return nil | |
| end | |
| data = Nokogiri::HTML(io) | |
| # process | |
| return data | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment