ruby - Nokogiri 和 Open-Uri 的警告消息
问题描述
您好,我有一条错误消息,如下所示:
警告:不推荐通过 Kernel#open 调用 URI.open,直接调用 URI.open 或使用 URI#open
我不明白为什么会出现此消息,我也尝试了 URI.open ("link") 命令。读
但我必须使用 Nokogiri。
这是我的代码:
require 'nokogiri'
require 'open-uri'
puts "Wait a second data is coming..."
PAGE_URL = "https://coinmarketcap.com/all/views/all/"
page = Nokogiri::HTML(open(PAGE_URL))
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
提前致谢。
解决方案
推荐阅读
- android-source - 构建aosp时为键盘添加两种语言
- python - 使用用户名更新排行榜
- jquery - 使用 jQuery Datatable 搜索时如何防止触发 ajax?
- c# - MediaPlayer 自定义流源
- javascript - Angular6 - 更改值时的动画
- javascript - Backbone JS 按钮打开一个新视图,保存表单中的值
- .net - 无法在 IIS 上部署
- mne-python - 如何使用 python-MNE 获取没有事件和纪元的静止状态 MEG 数据
- android - 无法为 Android 构建 ffmpeg
- r - 如何在 c() 函数中使用连接的字符串作为名称