This is a creation in Article, where the information may have evolved or changed.
See many spider versions on the web, almost all using regexp Kanemasa match implementation.
Actually use Doc for better performance and more elegance
PackageMainImport("FMT""Net/http""OS""Golang.org/x/net/html")funcVisit(Links []string, N *html. Node) []string{offN.type = = html.Elementnode&& N.data = =' A '{ for_, A: =Rangen.attr {ifA.key = ="href"{links =Append(Links, A.val)}}} forc: = N.firstchild; c! =Nil; c = c.nextsibling {links =Visit(Links, c)}returnLinksfuncMain() { for_, URL: =RangeOs. args[1:] {Links, ERR: =FindLinks(URL)ifErr! =Nil{FMT.fprintf(OS. Stderr, "FINDLINKS2:%v\n", ErrContinue } for_, Link: =RangeLinks {fmt.Println(link)} }}funcFindLinks(URLstring) ([]string, Error) {RESP, ERR: = http.Get(URL)ifErr! =Nil{returnNil, ERR}ifResp. StatusCode! = http.Statusok{resp. Body.Close()returnNil, Fmt.Errorf("Getting%s:%s", Url, Resp. Status)} doc, ERR: = HTML.Parse(resp. Body) resp. Body.Close()ifErr! =Nil{returnNil, Fmt.Errorf("Pax resing%s as HTML:%v", wr., ERR)}returnVisit(Nil, Doc, Nil}