完善
This commit is contained in:
parent
d675a17741
commit
233738f52f
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user