// return a list for Repositories url // // http://godoc.org/code.google.com/p/go.tools // http://godoc.org/code.google.com/p/go.crypto // http://godoc.org/code.google.com/p/go.image // ... func SubRepoUrls(url string) (urls []string) { node := MustParse(url) h2list := htmlhelper.GetElementsByTagName(node, "h2") if h2list == nil { return } var repo *html.Node for _, node := range h2list { if strings.TrimSpace(htmlhelper.Text(node)) == "Repositories" { repo = NextSibling(node) } } hrefs := htmlhelper.GetElementsByTagName(repo, "a") for _, node := range hrefs { urls = append(urls, "http://godoc.org/"+htmlhelper.Text(node)) } return }
func DirectoryURLs(url string) (urls []string) { node := MustParse(url) h3 := htmlhelper.GetElementById(node, "pkg-subdirectories") if h3 == nil { return } hrefs := htmlhelper.GetElementsByTagName(NextSibling(h3), "a") for _, node := range hrefs { urls = append(urls, "http://godoc.org"+htmlhelper.NodeAttr(node, "href")) } return }