From 233738f52fc1392f9af21b090f7922dfd8c3d4be Mon Sep 17 00:00:00 2001 From: xing Date: Fri, 14 Apr 2023 23:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bbclearn/bbc.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bbclearn/bbc.go b/bbclearn/bbc.go index 0344610..1ed9996 100644 --- a/bbclearn/bbc.go +++ b/bbclearn/bbc.go @@ -3,7 +3,6 @@ package bbclearn import ( "fmt" "github.com/PuerkitoBio/goquery" - strings2 "github.com/fthvgb1/wp-go/helper/strings" "github.com/fthvgb1/wp-go/rss2" "net/http" "strings" @@ -30,12 +29,20 @@ func LearnParse(s string, recentDay int) string { return rss.GetXML() } -func dateFilter(u string, recentDay int) (r bool) { +func parseTime(u string) (date time.Time, err error) { uu := strings.Split(u, "-") if len(uu) < 2 { return } - date, err := time.Parse("060102", uu[len(uu)-1]) + date, err = time.Parse("060102", uu[len(uu)-1]) + if err != nil { + return + } + return +} + +func dateFilter(u string, recentDay int) (r bool) { + date, err := parseTime(u) if err != nil { return } @@ -66,12 +73,8 @@ func fetch(u string) (r rss2.Item) { return } r.Title = s.Find(`div[data-widget-index="3"] h3`).Text() - - r.PubDate = strings.TrimSpace(s.Find(".widget-bbcle-featuresubheader").Text()) - r.PubDate = strings2.Replace(r.PubDate, map[string]string{ - "\n": "", - }) - r.PubDate = strings2.CutSpecialDuplicate(r.PubDate, " ") + date, _ := parseTime(u) + r.PubDate = date.Format(time.RFC1123Z) r.Guid = u r.Description = content return