完善
This commit is contained in:
parent
d675a17741
commit
233738f52f
|
@ -3,7 +3,6 @@ package bbclearn
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
strings2 "github.com/fthvgb1/wp-go/helper/strings"
|
|
||||||
"github.com/fthvgb1/wp-go/rss2"
|
"github.com/fthvgb1/wp-go/rss2"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -30,12 +29,20 @@ func LearnParse(s string, recentDay int) string {
|
||||||
return rss.GetXML()
|
return rss.GetXML()
|
||||||
}
|
}
|
||||||
|
|
||||||
func dateFilter(u string, recentDay int) (r bool) {
|
func parseTime(u string) (date time.Time, err error) {
|
||||||
uu := strings.Split(u, "-")
|
uu := strings.Split(u, "-")
|
||||||
if len(uu) < 2 {
|
if len(uu) < 2 {
|
||||||
return
|
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 {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -66,12 +73,8 @@ func fetch(u string) (r rss2.Item) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
r.Title = s.Find(`div[data-widget-index="3"] h3`).Text()
|
r.Title = s.Find(`div[data-widget-index="3"] h3`).Text()
|
||||||
|
date, _ := parseTime(u)
|
||||||
r.PubDate = strings.TrimSpace(s.Find(".widget-bbcle-featuresubheader").Text())
|
r.PubDate = date.Format(time.RFC1123Z)
|
||||||
r.PubDate = strings2.Replace(r.PubDate, map[string]string{
|
|
||||||
"\n": "",
|
|
||||||
})
|
|
||||||
r.PubDate = strings2.CutSpecialDuplicate(r.PubDate, " ")
|
|
||||||
r.Guid = u
|
r.Guid = u
|
||||||
r.Description = content
|
r.Description = content
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user