From 2a6cdae8b8ea070000e9870c1df872c2adbb48a3 Mon Sep 17 00:00:00 2001 From: demo Date: Thu, 28 May 2026 13:16:12 -0400 Subject: feat: save sitemap to a file --- classic.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/classic.go b/classic.go index e30f3b3..709271f 100644 --- a/classic.go +++ b/classic.go @@ -6,6 +6,7 @@ import ( "fmt" "log" "net/url" + "os" "sync" "golang.org/x/net/html" @@ -80,7 +81,13 @@ loop: log.Fatal(err) } - fmt.Println(sitemap) + xmlFilename := fmt.Sprintf("%s.xml", startURL.Host) + + if err := os.WriteFile(xmlFilename, []byte(sitemap), 0666); err != nil { + log.Fatal(err) + } + + fmt.Printf("Wrote sitemap to %s\n", xmlFilename) } func getBatch(u url.URL) []url.URL { -- cgit v1.2.3