hubcap links

Extract all links from the current page.

When to use

Use links to get every anchor element’s href and text content. Useful for crawling, sitemap validation, or checking for broken links.

Usage

hubcap links

Arguments

None.

Flags

None.

Output

FieldTypeDescription
linksarrayArray of link objects
links[].hrefstringThe href attribute value
links[].textstringThe visible text content of the link
{
  "links": [
    {
      "href": "https://example.com/about",
      "text": "About Us"
    },
    {
      "href": "https://example.com/contact",
      "text": "Contact"
    }
  ]
}

Errors

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

Examples

List all links on the page:

hubcap links

Extract only external links:

hubcap links | jq '[.links[] | select(.href | startswith("http")) | select(.href | contains("example.com") | not)]'

Check each link for broken URLs by piping into curl:

hubcap links | jq -r '.links[].href' | while read -r url; do
  STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$url")
  echo "$STATUS $url"
done

See also

  • meta - get meta tags from the page
  • images - list all images on the page
  • scripts - list all script elements