You can use Ruby's built-in Net::HTTP
library to make HTTP requests, including GET requests. Here's an example:
main.rb231 chars11 lines
In this example, we first parse the URL we want to make a request to using URI.parse()
. We then create a new Net::HTTP::Get
object, passing in the parsed URI. We make the request using Net::HTTP.start()
, passing in the hostname, port, and use_ssl
flag. Finally, we output the response's body to the console using puts response.body
.
gistlibby LogSnag