Class: Ronin::Web::CLI::Commands::Html Private

Inherits:
Xml show all
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
-t, --text                       Prints the inner-text
-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

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Xml

#read

Instance Attribute Details

#queryString? (readonly)

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.

The XPath or CSS-path query.

Returns:

  • (String, nil)

Since:

  • 1.0.0



126
127
128
# File 'lib/ronin/web/cli/commands/html.rb', line 126

def query
  @query
end

Instance Method Details

#parse(html) ⇒ Nokogiri::HTML::Document

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.

Parses the HTML source code.

Parameters:

  • html (String)

    The raw unparsed HTML.

Returns:

  • (Nokogiri::HTML::Document)

    The parsed HTML document.

Since:

  • 1.0.0



155
156
157
# File 'lib/ronin/web/cli/commands/html.rb', line 155

def parse(html)
  Nokogiri::HTML(html)
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.

Parameters:

  • source (String)

    The URL or FILE argument.

  • query (String, nil) (defaults to: @query)

    The optional XPath or CSS-path argument.

Since:

  • 1.0.0



137
138
139
140
141
142
143
144
# 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

  super(source,query)
end