Module: Ronin::Support::Web::Agent::Mixin
- Included in:
- Mixin
- Defined in:
- lib/ronin/support/web/agent/mixin.rb
Overview
Provides helper methods for performing high-level web requests.
Features
- Automatically follows redirects.
- Provides high-level methods for requesting and parsing HTML, XML, or JSON.
- Maintains a persistent connection pool.
Anti-Features
- Does not cache files or write to the disk.
- Does not evaluate JavaScript.
Instance Method Summary collapse
-
#web_agent ⇒ Agent
The web agent object.
-
#web_get(url, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
(also: #get)
Gets a URL and returns the response.
-
#web_get_html(url, **kwargs) ⇒ Nokogiri::HTML::Document
(also: #get_html)
Gets the URL and returns the parsed HTML.
-
#web_get_json(url, **kwargs) ⇒ Hash{String => Object}, Array
(also: #get_json)
Gets the URL and returns the parsed JSON.
-
#web_get_xml(url, **kwargs) ⇒ Nokogiri::XML::Document
(also: #get_xml)
Gets the URL and returns the parsed XML.
-
#web_post(url, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
(also: #post)
Performs an HTTP POST to the URL.
-
#web_post_html(url, **kwargs) ⇒ Nokogiri::HTML::Document
(also: #post_html)
Performs an HTTP POST to the URL and parses the HTML response.
-
#web_post_json(url, **kwargs) ⇒ Hash{String => Object}, Array
(also: #post_json)
Performs an HTTP POST to the URL and parses the JSON response.
-
#web_post_xml(url, **kwargs) ⇒ Nokogiri::XML::Document
(also: #post_xml)
Performs an HTTP POST to the URL and parses the XML response.
Instance Method Details
#web_agent ⇒ Agent
The web agent object.
48 49 50 |
# File 'lib/ronin/support/web/agent/mixin.rb', line 48 def web_agent @web_agent ||= Agent.new end |
#web_get(url, **kwargs) {|response| ... } ⇒ Net::HTTPResponse Also known as: get
This method will follow redirects by default.
Gets a URL and returns the response.
130 131 132 |
# File 'lib/ronin/support/web/agent/mixin.rb', line 130 def web_get(url,**kwargs,&block) web_agent.get(url,**kwargs,&block) end |
#web_get_html(url, **kwargs) ⇒ Nokogiri::HTML::Document Also known as: get_html
This method will follow redirects by default.
Gets the URL and returns the parsed HTML.
159 160 161 |
# File 'lib/ronin/support/web/agent/mixin.rb', line 159 def web_get_html(url,**kwargs) web_agent.get_html(url,**kwargs) end |
#web_get_json(url, **kwargs) ⇒ Hash{String => Object}, Array Also known as: get_json
This method will follow redirects by default.
Gets the URL and returns the parsed JSON.
218 219 220 |
# File 'lib/ronin/support/web/agent/mixin.rb', line 218 def web_get_json(url,**kwargs) web_agent.get_json(url,**kwargs) end |
#web_get_xml(url, **kwargs) ⇒ Nokogiri::XML::Document Also known as: get_xml
This method will follow redirects by default.
Gets the URL and returns the parsed XML.
188 189 190 |
# File 'lib/ronin/support/web/agent/mixin.rb', line 188 def web_get_xml(url,**kwargs) web_agent.get_xml(url,**kwargs) end |
#web_post(url, **kwargs) {|response| ... } ⇒ Net::HTTPResponse Also known as: post
If the response is an HTTP redirect, then #get will be called to follow any redirects.
Performs an HTTP POST to the URL.
252 253 254 |
# File 'lib/ronin/support/web/agent/mixin.rb', line 252 def web_post(url,**kwargs,&block) web_agent.post(url,**kwargs,&block) end |
#web_post_html(url, **kwargs) ⇒ Nokogiri::HTML::Document Also known as: post_html
If the response is an HTTP redirect, then #get will be called to follow any redirects.
Performs an HTTP POST to the URL and parses the HTML response.
284 285 286 |
# File 'lib/ronin/support/web/agent/mixin.rb', line 284 def web_post_html(url,**kwargs) web_agent.post_html(url,**kwargs) end |
#web_post_json(url, **kwargs) ⇒ Hash{String => Object}, Array Also known as: post_json
If the response is an HTTP redirect, then #get will be called to follow any redirects.
Performs an HTTP POST to the URL and parses the JSON response.
352 353 354 |
# File 'lib/ronin/support/web/agent/mixin.rb', line 352 def web_post_json(url,**kwargs) web_agent.post_json(url,**kwargs) end |
#web_post_xml(url, **kwargs) ⇒ Nokogiri::XML::Document Also known as: post_xml
If the response is an HTTP redirect, then #get will be called to follow any redirects.
Performs an HTTP POST to the URL and parses the XML response.
316 317 318 |
# File 'lib/ronin/support/web/agent/mixin.rb', line 316 def web_post_xml(url,**kwargs) web_agent.post_xml(url,**kwargs) end |