1

I have a ruby web crawler that is currently coded to run in firefox. How do I switch it over to Chrome instead?

def open_browser()
  tweaked_profile = Selenium::WebDriver::Firefox::Profile.new
  tweaked_profile['nglayout.initialpaint.delay'] = 0
  tweaked_profile.assume_untrusted_certificate_issuer=false
  tweaked_profile['permissions.default.image'] = 2
  tweaked_profile['network.proxy.type'] = 1
  tweaked_profile['network.proxy.http'] = 'ec2proxy.csnzoo.com'
  tweaked_profile['network.proxy.http_port'] = 8080
  driver = Selenium::WebDriver.for :firefox, :profile => tweaked_profile
  $browser = Watir::Browser.new(driver)
end

Should I just ditch watir and go with chromedriver or will watir work for this?

Chuck van der Linden
  • 6,660
  • 2
  • 28
  • 43

1 Answers1

3

Check out http://watirwebdriver.com/chrome/, which has this example:

profile = Selenium::WebDriver::Chrome::Profile.new
... 
b = Watir::Browser.new :chrome, :profile => profile

Also, these SO questions provide alternatives for crawling sites: Web crawler in ruby and What are some good Ruby-based web crawlers?

Community
  • 1
  • 1
orde
  • 5,233
  • 6
  • 31
  • 33