From 98540a76eea68e8fd208829e27bfab3180f20484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Tue, 11 Jun 2024 20:22:15 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=A1=E3=82=93=E3=81=A1=E3=82=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routedetail.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/routedetail.go b/src/routedetail.go index a465c2e..0587223 100755 --- a/src/routedetail.go +++ b/src/routedetail.go @@ -2,6 +2,7 @@ package src import ( "strings" + "regexp" "github.com/gocolly/colly" ) @@ -23,12 +24,15 @@ func handleFare(el *colly.HTMLElement, f Fare, s Stop) Fare { fixAir := strings.ReplaceAll(fixBus, "[air]", "【空路】") fixEki := strings.ReplaceAll(fixAir, "当駅始発", "【当駅始発】") + pattern := regexp.MustCompile(`(線)([^\s行]*行)`) + f.Train = fixEki f.Platform = el.ChildText("li.platform") f.Color = strings.ReplaceAll(el.ChildAttr("span", "style"), "border-color:#", "") el.ForEach("li.stop ul", func (js int, els *colly.HTMLElement) { s.Time = els.ChildText("li dl dt") - s.Name = strings.ReplaceAll(els.ChildText("li dl dd"), "○", "") + sname := strings.ReplaceAll(els.ChildText("li dl dd"), "○", "") + s.Name = pattern.ReplaceAllString(sname, "$1 $2") f.Stops = append(f.Stops, s) })