Created
January 5, 2019 18:25
-
-
Save guitarrapc/0474e44e57d6f806a38fa4aba3f8cdec to your computer and use it in GitHub Desktop.
retrieve sitemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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