Sha256: 39d095ca4987722fff785f24a592bd0bdbf18f4fb2c343e03d837bf15741470f
Contents?: true
Size: 760 Bytes
Versions: 1
Compression:
Stored size: 760 Bytes
Contents
require "ferrum" class BrowsingFacade include Singleton def visit(url:) @override_status = nil browser.go_to(url) rescue Ferrum::PendingConnectionsError, Ferrum::TimeoutError, Ferrum::StatusError @override_status = 500 end def code return @override_status if @override_status if browser.network.traffic[0]&.response&.status == 301 301 else browser.network.status end end def cleanup browser.reset end # If code was 301 then redirect_to will return the new url. def redirect_to browser.network.traffic[0].response.headers["Location"] end def quit browser.quit @browser = nil end def browser @browser ||= Ferrum::Browser.new(timeout: 30) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
browsing_facade-1.0.0 | lib/browsing_facade.rb |