Listing all hyperlinks in a page

For the introduction to the goquery package, we'll look at a common and simple task. We will find all hyperlinks in a page and print them out. A typical link looks something like this:

<a href="https://www.devdungeon.com">DevDungeon</a>  

In HTML, the a tag stands for anchor and the href attribute stands for hyperlink reference. It is possible to have an anchor tag with no href attribute but only a name attribute. These are called bookmarks, or named anchors, and are used to jump to a location on the same page. We will ignore these since they only link within the same page. The target attribute is just an optional one specifying which window or tab to open the link in. We are only interested in the href value ...

Get Security with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.