Return the href attribute of the second anchor element in an HTML file

xmllint

  • XML parser and linter that supports XPath, a syntax for navigating XML trees.
    More information: <https://manned.org/xmllint>.
  • Trick copyright: tl;dr; <https://github.com/tldr-pages/tldr>

xmllint --html --xpath "string(//a[2]/@href)" webpage.xhtml

click the source code to copy install xmllint on any operating system with command-not-found.com