lib/video_grabber/scraper.rb in video_grabber-1.7.0 vs lib/video_grabber/scraper.rb in video_grabber-1.8.0
- old
+ new
@@ -1,18 +1,19 @@
module VideoGrabber
class Scraper
attr_reader :url, :browser, :timeout, :keep_browser_open, :headless_enabled,
- :firefox_extension_path, :profile, :html_attributes
+ :firefox_extension_path, :profile, :html_attributes, :browser_type
def initialize(config)
@keep_browser_open = config.keep_browser_open
@url = config.url
@timeout = config.timeout
@headless_enabled = config.headless_enabled
@firefox_extension_path = config.firefox_extension_path
@html_attributes = config.html_attributes
+ @browser_type = config.browser
end
def start
open_browser
browser.goto(url) ; self
@@ -51,13 +52,13 @@
private
def open_browser
start_headless
- @profile = ::Selenium::WebDriver::Firefox::Profile.new ; load_extension
+ @profile = ::Selenium::WebDriver::Firefox::Profile.new && load_extension if firefox_extension_path
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = timeout
- @browser = ::Watir::Browser.new(:firefox, profile: profile, http_client: client)
+ @browser = ::Watir::Browser.new(browser_type, profile: profile, http_client: client)
end
def start_headless
return unless headless_enabled