Class: Ronin::Web::CLI::Commands::Html Private
- Inherits:
-
Ronin::Web::CLI::Command
- Object
- Core::CLI::Command
- Ronin::Web::CLI::Command
- Ronin::Web::CLI::Commands::Html
- Defined in:
- lib/ronin/web/cli/commands/html.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Performs XPath/CSS-path queries on a URL or HTML file.
Usage
ronin-web html [options] {URL | FILE} [XPATH | CSS-path]
Options
-X, --xpath XPATH XPath query
-C, --css-path CSSPath CSS-path query
-M, --meta-tags Searches for all <meta ...> tags
-l, --links Searches for all <a href="..."> URLs
-S, --style Dumps all <style> tags
-s, --stylesheet-urls Searches for all <link type="text/css" href="..."/> URLs
-J, --javascript Dumps all javascript source code
-j, --javascript-urls Searches for all <script src="..."> URLs
-f, --form-urls Searches for all <form action="..."> URLS
-u, --urls Dumps all URLs in the page
-F, --first Only print the first match
-h, --help Print help information
Arguments
URL | FILE The URL or FILE to search
[XPATH | CSS-path] The XPath or CSS-path query
Instance Method Summary collapse
-
#read(source) ⇒ File, String
private
Reads a URI or file.
-
#run(source, query = @query) ⇒ Object
private
Runs the
ronin-web xpath
command.
Instance Method Details
#read(source) ⇒ File, String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Reads a URI or file.
162 163 164 165 166 167 168 169 |
# File 'lib/ronin/web/cli/commands/html.rb', line 162 def read(source) if source.start_with?('https://') || source.start_with?('http://') Support::Network::HTTP.get_body(source) else File.new(source) end end |
#run(source, query = @query) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Runs the ronin-web xpath
command.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/ronin/web/cli/commands/html.rb', line 137 def run(source,query=@query) unless query print_error "must specify --xpath, --css-path, or an XPath/CSS-path argument" exit(-1) end doc = Nokogiri::HTML(read(source)) nodes = if [:first] then [doc.at(query)] else doc.search(query) end nodes.each do |node| puts node end end |