Module: Ronin::Web
- Includes:
- OpenNamespace
- Defined in:
- lib/ronin/web.rb,
lib/ronin/web/cli.rb,
lib/ronin/web/xml.rb,
lib/ronin/web/html.rb,
lib/ronin/web/root.rb,
lib/ronin/web/version.rb,
lib/ronin/web/mechanize.rb,
lib/ronin/web/cli/command.rb,
lib/ronin/web/cli/ruby_shell.rb,
lib/ronin/web/cli/commands/irb.rb,
lib/ronin/web/cli/commands/new.rb,
lib/ronin/web/cli/commands/diff.rb,
lib/ronin/web/cli/commands/html.rb,
lib/ronin/web/cli/commands/server.rb,
lib/ronin/web/cli/commands/spider.rb,
lib/ronin/web/cli/commands/new/server.rb,
lib/ronin/web/cli/commands/new/spider.rb,
lib/ronin/web/cli/commands/new/webapp.rb,
lib/ronin/web/cli/commands/new/nokogiri.rb,
lib/ronin/web/cli/commands/reverse_proxy.rb
Overview
Top-level web helper methods.
Defined Under Namespace
Modules: HTML, XML Classes: CLI, Mechanize
Constant Summary collapse
- ROOT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Path to
ronin-web
root directory. File.(File.join(__dir__,'..','..','..'))
- VERSION =
ronin-web Version
'1.0.2'
Class Method Summary collapse
-
.agent ⇒ Mechanize
A persistent Mechanize Agent.
-
.build_html { ... } ⇒ Nokogiri::HTML::Builder
Creates a new Nokogiri::HTML::Builder.
-
.build_xml { ... } ⇒ Nokogiri::XML::Builder
Creates a new Nokogiri::XML::Builder.
-
.get(url, parameters = {}, headers = {}) {|page| ... } ⇒ Mechanize::Page
Creates a Mechanize Page for the contents at a given URL.
-
.get_body(url, parameters = {}, headers = {}) {|body| ... } ⇒ String
Requests the body of the Mechanize Page created from the response of the given URL.
-
.html(body) {|doc| ... } ⇒ Nokogiri::HTML::Document
Parses the body of a document into a HTML document object.
-
.open(url, proxy: Support::Network::HTTP.proxy, user_agent: Support::Network::HTTP.user_agent, referer: nil, cookie: nil, **kwargs) ⇒ File
Opens a URL as a temporary file.
-
.post(url, query = {}, headers = {}) {|page| ... } ⇒ Mechanize::Page
Posts to a given URL and creates a Mechanize Page from the response.
-
.post_body(url, query = {}, headers = {}) {|body| ... } ⇒ Mechanize::Page
Posts to a given URL and returns the body of the Mechanize Page created from the response.
-
.xml(body) {|doc| ... } ⇒ Nokogiri::XML::Document
Parses the body of a document into a XML document object.
Class Method Details
.agent ⇒ Mechanize
A persistent Mechanize Agent.
235 236 237 |
# File 'lib/ronin/web.rb', line 235 def self.agent @agent ||= Mechanize.new end |
.build_html { ... } ⇒ Nokogiri::HTML::Builder
Creates a new Nokogiri::HTML::Builder.
92 93 94 |
# File 'lib/ronin/web.rb', line 92 def self.build_html(&block) HTML.build(&block) end |
.build_xml { ... } ⇒ Nokogiri::XML::Builder
Creates a new Nokogiri::XML::Builder.
141 142 143 |
# File 'lib/ronin/web.rb', line 141 def self.build_xml(&block) XML.build(&block) end |
.get(url, parameters = {}, headers = {}) {|page| ... } ⇒ Mechanize::Page
Creates a Mechanize Page for the contents at a given URL.
276 277 278 |
# File 'lib/ronin/web.rb', line 276 def self.get(url,parameters={},headers={},&block) agent.get(url,parameters,nil,headers,&block) end |
.get_body(url, parameters = {}, headers = {}) {|body| ... } ⇒ String
Requests the body of the Mechanize Page created from the response of the given URL.
314 315 316 317 318 319 |
# File 'lib/ronin/web.rb', line 314 def self.get_body(url,parameters={},headers={}) body = get(url,parameters,headers).body yield body if block_given? return body end |
.html(body) {|doc| ... } ⇒ Nokogiri::HTML::Document
Parses the body of a document into a HTML document object.
64 65 66 |
# File 'lib/ronin/web.rb', line 64 def self.html(body,&block) HTML.parse(body,&block) end |
.open(url, proxy: Support::Network::HTTP.proxy, user_agent: Support::Network::HTTP.user_agent, referer: nil, cookie: nil, **kwargs) ⇒ File
Opens a URL as a temporary file.
The User-Agent
string to use.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/ronin/web.rb', line 202 def self.open(url, proxy: Support::Network::HTTP.proxy, user_agent: Support::Network::HTTP.user_agent, referer: nil, cookie: nil, **kwargs) uri = URI(url) = {proxy: proxy, **kwargs} if user_agent ['User-Agent'] = case user_agent when Symbol Support::Network::HTTP::UserAgents[user_agent] else user_agent end end ['Referer'] = referer if referer ['Cookie'] = if return uri.open() end |
.post(url, query = {}, headers = {}) {|page| ... } ⇒ Mechanize::Page
Posts to a given URL and creates a Mechanize Page from the response.
351 352 353 |
# File 'lib/ronin/web.rb', line 351 def self.post(url,query={},headers={},&block) agent.post(url,query,headers,&block) end |
.post_body(url, query = {}, headers = {}) {|body| ... } ⇒ Mechanize::Page
Posts to a given URL and returns the body of the Mechanize Page created from the response.
390 391 392 393 394 395 |
# File 'lib/ronin/web.rb', line 390 def self.post_body(url,query={},headers={}) body = post(url,query,headers).body yield body if block_given? return body end |