geturl.go 864 B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "strings"
  4. "net/url"
  5. )
  6. func b2s (val bool) string {
  7. if val { return "1" }
  8. return "0"
  9. }
  10. func geturl (f Opts) string {
  11. date := strings.Split(f.Date, "-")
  12. year := date[0]
  13. month := date[1]
  14. day := date[2]
  15. hour := strings.Split(f.Time, ":")[0]
  16. minute := strings.Split(f.Time, ":")[1]
  17. m1 := string(minute[0])
  18. m2 := string(minute[1])
  19. curl, _ := url.Parse("https://transit.yahoo.co.jp/search/result?from=" + url.QueryEscape(f.From) + "&to=" + url.QueryEscape(f.To) + "&y=" + year + "&m=" + month + "&d=" + day + "&hh=" + hour + "&m1=" + m1 + "&m2=" + m2 + "&type=" + f.Mode + "&ticket=ic&expkind=1&userpass=1&ws=" + f.Route + "&al=" + b2s(f.NoAirplane) + "&shin=" + b2s(f.NoShinkansen) + "&ex=" + b2s(f.NoExpress) + "&hb=" + b2s(f.NoExpressBus) + "&lb=" + b2s(f.NoBus) + "&sr=" + b2s(f.NoFairy))
  20. return curl.String()
  21. }