Ruby open-uri can't open url (m1 mac)
The problem is likely that you are using ruby 3.0.0.
Under Ruby 2.7, I receive the following warning:
warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open
And under Ruby 3.0, it has been removed.
So the solution, per the warning:
document = URI.open("https://en.wikipedia.org/wiki/Douglas_Adams").read
Ruby open-uri throws an Bad uri error when I try to get a URL through user input. Why?
gets
adds a new line character to the end of the string. I have used chomp
on the gets to remove this below.
It should work now
require 'nokogiri'
require 'open-uri'
get_url = gets.chomp
doc = Nokogiri::HTML(open(get_url))
puts doc
Related Topics
How to Download File from Google Drive API with Service Account
What Is the Ruby Equivalent of Preg_Quote()
Iterate Through Array of Hashes in Ruby
How to Set the Mechanize Page Encoding
Rvm and Gems, Bundle Show and Gem List
Spring Doesn't Work. [ Uninitialized Constant Spring::Sid::Dl ]
Why Is the Timezone Off in Delayed_Job
Validating Phone Number in Ruby
Ruby Open-Uri Can't Open Url (M1 MAC)
Why Does My Recursive Method from Helper Not Return Every Value
Why Can't I Change the Value of Self
Gem Install Therubyracer -V 0.11.4 Fails on Os X 10.10
How to Convert This Ruby String into an Array
Differencebetween a Constant and a Variable in Ruby
Why Rails Can Use 'If' as Hash Key But Not in Ruby
Ruby on Rails: Fully Functional Tableless Model