Module: Ronin::Web::Browser
- Defined in:
- lib/ronin/web/browser.rb,
lib/ronin/web/browser/agent.rb,
lib/ronin/web/browser/cookie.rb,
lib/ronin/web/browser/version.rb,
lib/ronin/web/browser/cookie_file.rb
Overview
Automates a Chrome web browser.
Examples
Initialize a headless browser:
browser = Ronin::Web::Browser.new
# ...
browser.quit
Initialize a visible browser:
browser = Ronin::Web::Browser.new(visible: true)
# ...
browser.quit
Opening a temporary browser and automatically quitting:
Ronin::Web::Browser.open do |browser|
# ...
end
Initializing the browser with a proxy:
browser = Ronin::Web::Browser.new(proxy: "http://proxy.example.com:8080")
# ...
Go to and screenshot a webpage:
Ronin::Web::Browser.open do |browser|
browser.go_to("https://google.com")
browser.screenshot(path: "google.png")
end
Intercept all requests:
browser = Ronin::Web::Browser.new
browser.network.intercept
browser.on(:request) do |request|
puts "> #{request.method} #{request.url}"
request.continue
end
browser.go_to("https://twitter.com/login")
Intercept all responses for all requests:
browser = Ronin::Web::Browser.new
browser.on(:response) do |exchange|
puts "> #{exchange.request.method} #{exchange.request.url}"
puts "< HTTP #{exchange.response.status}"
exchange.response.headers.each do |name,value|
puts "< #{name}: #{value}"
end
puts exchange.response.body
end
browser.go_to("https://twitter.com/login")
See ferrum for additional documentation.
Defined Under Namespace
Classes: Agent, Cookie, CookieFile
Constant Summary collapse
- VERSION =
ronin-web-browser version
'0.1.0'
Class Method Summary collapse
-
.new(**kwargs) ⇒ Agent
Initializes the browser agent.
-
.open(**kwargs) {|browser| ... } ⇒ Agent
Opens a new browser.