Last active
February 27, 2023 20:09
-
-
Save thomasjslone/e0ef0299fac753e94addbcd214e0acb7 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
require "open-uri" | |
require "net/http" | |
require "openssl" | |
@page = "unloaded" | |
@html = "unloaded" | |
uri = URI.parse(ARGV[0] || 'https://en.wikipedia.org/wiki/Hydrogen') | |
http = Net::HTTP.new(uri.host, uri.port) | |
if uri.scheme == "https" # enable SSL/TLS | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
http.ca_file = Dir.getwd.to_s + "/cacert.pem" | |
end | |
@page = http.start { | |
http.request_get(uri.path) {|res| | |
@html = res.body | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment