i start to learn ruby and scraping and i try to open an url with open and i got
lib/scrapper.rb:7:in `initialize': No such file or directory @ rb_sysopen - https://en.wikipedia.org/wiki/Douglas_Adams (Errno::ENOENT) from lib/scrapper.rb:7:in `open' from lib/scrapper.rb:7:in `<main>'
And this is my code :
# frozen_string_literal: true
require 'rubygems'
require 'open-uri'
require 'nokogiri'
document = open("https://en.wikipedia.org/wiki/Douglas_Adams")
puts document
After some long hours of google research i don't find any solution 😠I test open with this url to : http://www.krosmoz.com/fr/almanax thanks all 🧅
ps i'm on mac m1 don't know if they are compatibility issues
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With