问题描述
我的程序中有一条错误消息,我不明白为什么。我在谷歌上做了一些关于什么是“require 'open-uri' 缺失的研究,但正如你在我下面的代码中看到的那样,它被很好地包含在内。这是我的错误消息,在我的代码下方。
我的错误:
app.rb:10:in `initialize': No such file or directory @ rb_sysopen - https://coinmarketcap.com/all/views/all/ (Errno::ENOENT)
from app.rb:10:in `open'
from app.rb:10:in `<main>''
我的代码:
require 'nokogiri'
require 'open-uri'
puts "Wait a second data is coming..."
PAGE_URL = "https://coinmarketcap.com/all/views/all/"
page = Nokogiri::HTML(open("https://coinmarketcap.com/all/views/all/"))
currency_name_array = page.xpath("//tr/td/a[contains(@class,'currency-name-container')]/text()").map {|x| x.to_s }
currency_value_array = page.xpath("//tr/td/a[contains(@class,'price')]/text()").map {|x| x.to_s }
currency_result = Hash[currency_name_array.zip(currency_value_array)]
puts currency_result
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)