hubcap source

Get the full HTML source of the current page.

When to use

Use source to retrieve the complete outer HTML of the document. Use html <selector> to get the outer HTML of a specific element instead of the entire page.

Usage

hubcap source

Arguments

None.

Flags

None.

Output

FieldTypeDescription
htmlstringThe full HTML source of the document
{
  "html": "<!DOCTYPE html><html><head><title>Example</title></head><body><h1>Hello</h1></body></html>"
}

Errors

ConditionExit codeStderr
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Get the page source:

hubcap source

Save the page HTML to a file:

hubcap source | jq -r '.html' > page.html

Check whether the page contains a specific string:

hubcap source | jq -r '.html' | grep -q "viewport" && echo "Has viewport meta"

Pipe the source into an external validator:

hubcap source | jq -r '.html' | html-validate -

See also

  • html - get outer HTML of a specific element
  • info - get combined page information