9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/crabfarm/modes/recorder.rb', line 9
def self.start(_target)
return puts "Must provide a recording name" unless _target.is_a? String
crabtrap_config = Crabfarm.config.crabtrap_config
crabtrap_config[:mode] = :capture
crabtrap_config[:bucket_path] = File.join(CF_PATH, 'spec/mementos', _target + '.json.gz')
crabtrap = CrabtrapRunner.new crabtrap_config
crabtrap.start
driver_config = Crabfarm.config.driver_config
driver_config[:name] = :firefox
driver_config[:proxy] = "127.0.0.1:#{crabtrap.port}"
driver = DefaultDriverFactory.new(driver_config).build_driver nil
begin
puts "Press Ctrl-C to stop capturing."
loop do
driver.current_url
sleep 1.0
end
rescue Selenium::WebDriver::Error::WebDriverError, SystemExit, Interrupt
end
puts "Releasing crawling context".color(:green)
driver.quit rescue nil
crabtrap.stop
end
|