Skip to content

Instantly share code, notes, and snippets.

@thomasjslone
Last active February 27, 2023 20:09
Show Gist options
  • Save thomasjslone/e0ef0299fac753e94addbcd214e0acb7 to your computer and use it in GitHub Desktop.
Save thomasjslone/e0ef0299fac753e94addbcd214e0acb7 to your computer and use it in GitHub Desktop.
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