我正在尝试使用机械化进行网页抓取,但它在开始时已经给我一个错误。
require 'rubygems'
require "mechanize"
agent = Mechanize.new { |agent|
agent.user_agent_alias = 'Mac Safari'
}
page = agent.get('https://www.wikipedia.org/')
searchForm = page.form(:action => '//www.wikipedia.org/search-redirect.php')
错误看起来像
C:/Users/user/eclipse-workspace/proj/mechanize.rb:4:in `<top (required)>': uninitialized constant Mechanize (NameError)
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/Users/user/eclipse-workspace/proj/mechanize.rb:2:in `<main>'