不能将PhantomJS与Selenium一起使用?

时间:2018-08-15 01:41:49

标签: ruby selenium webdriver phantomjs web-crawler

错误:

/Users/omega/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- selenium/webdriver/phantomjs (LoadError)
from /Users/omega/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from /Users/omega/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/common/driver.rb:50:in `for'
from /Users/omega/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver.rb:86:in `for'
from crawl.rb:9:in `<main>'

Ruby版本:

ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin17]

宝石文件:

source "http://rubygems.org"

gem 'httparty'
gem 'nokogiri'
gem "selenium-webdriver"
gem 'phantomjs'
gem 'dotenv'

Crawl.rb:

require 'nokogiri'
require 'httparty'
require "selenium-webdriver"
require 'phantomjs'

# input = gets
@driver = Selenium::WebDriver.for :phantomjs

在阅读注释@Subash之后,尝试无头镀铬是个好主意。

0 个答案:

没有答案