Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Created January 5, 2019 18:25
Show Gist options
  • Save guitarrapc/0474e44e57d6f806a38fa4aba3f8cdec to your computer and use it in GitHub Desktop.
Save guitarrapc/0474e44e57d6f806a38fa4aba3f8cdec to your computer and use it in GitHub Desktop.
retrieve sitemap
package main
import (
"fmt"
"os"
sitemap "github.com/yterajima/go-sitemap"
)
func main() {
if len(os.Args) != 2 {
fmt.Fprintf(os.Stderr, "Usage: %s URL\n", os.Args[0])
os.Exit(1)
}
sitemapURL := os.Args[1] + "/sitemap.xml"
xml, err := sitemap.Get(sitemapURL, nil)
if err != nil {
fmt.Println(err)
return
}
for _, loc := range xml.URL {
fmt.Println(loc.Loc)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment