2023-05-10 22:47:27 +09:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"time"
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
2023-05-11 07:17:45 +09:00
|
|
|
"path/filepath"
|
2023-05-10 22:47:27 +09:00
|
|
|
)
|
|
|
|
|
2023-05-11 07:17:45 +09:00
|
|
|
func checkexist (url string, prefix string) []string {
|
|
|
|
res, err := filepath.Glob(prefix + "/archive/*" + url2path(url))
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Err:", err)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}
|
2023-05-10 22:47:27 +09:00
|
|
|
|
2023-05-11 07:17:45 +09:00
|
|
|
func url2path (url string) string {
|
|
|
|
res := ""
|
2023-05-10 22:47:27 +09:00
|
|
|
if strings.HasPrefix(url, "https:/") {
|
2023-05-11 07:17:45 +09:00
|
|
|
res = strings.Replace(url, "https:/", "", 1)
|
2023-05-10 22:47:27 +09:00
|
|
|
} else {
|
2023-05-11 07:17:45 +09:00
|
|
|
res = strings.Replace(url, "http:/", "", 1)
|
2023-05-10 22:47:27 +09:00
|
|
|
}
|
|
|
|
|
2023-05-11 07:17:45 +09:00
|
|
|
if strings.HasSuffix(res, "/") {
|
|
|
|
res = strings.TrimSuffix(res, "/")
|
2023-05-10 22:47:27 +09:00
|
|
|
}
|
|
|
|
|
2023-05-11 07:17:45 +09:00
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
func mkdirs (url string, prefix string) string {
|
|
|
|
rep := url2path(url)
|
|
|
|
t := time.Now().Unix()
|
|
|
|
|
2023-05-10 22:47:27 +09:00
|
|
|
path := fmt.Sprint(prefix, "/archive/", t, rep)
|
|
|
|
cmd := exec.Command("mkdir", "-p", path)
|
|
|
|
|
|
|
|
cmd.Run()
|
|
|
|
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
|
|
|
|
//func getpage (url string, path string) {}
|
|
|
|
|
|
|
|
//func scanpage (path string) {}
|