googleで株価の検索件数 ruby

gem install nokogirl
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.


$ sudo gem install nokogirl

It's actually spelled nokogiri, not nokogirl

Successfully installed nokogirl-1.0
Parsing documentation for nokogirl-1.0
Done installing documentation for nokogirl after 0 seconds
1 gem installed
require 'nokogiri'
require 'open-uri'
require 'uri'
require 'cgi'
escaped_url = URI.escape("株価")
doc = Nokogiri::HTML(open(escaped_url))
puts doc.xpath("//*[@id='resultStats']/text()")
$ ruby google.rb 
約 66,600,000

株価だけで66,600,000 件もヒットするだね。