add debug log

This commit is contained in:
Jay 2018-09-21 08:38:49 +08:00
parent 203cc30867
commit 87db887072

View File

@ -39,6 +39,7 @@ func (pd byTime) Less(i, j int) bool { return pd[i].Time < pd[j].Time }
func readFacebookPage() { func readFacebookPage() {
pages, err := model.GetAllFacebookPage() pages, err := model.GetAllFacebookPage()
if err != nil { if err != nil {
fmt.Println("get page data err ", err)
return return
} }
@ -50,16 +51,19 @@ func readFacebookPage() {
func getPageHTML(page *model.FacebookPage) { func getPageHTML(page *model.FacebookPage) {
err := page.GetGroups() err := page.GetGroups()
if err != nil { if err != nil {
fmt.Println("get page group err ", err)
return return
} }
resp, err := http.Get(fmt.Sprintf("https://www.facebook.com/%s", page.ID)) resp, err := http.Get(fmt.Sprintf("https://www.facebook.com/%s", page.ID))
if err != nil { if err != nil {
fmt.Println("get page html err ", err)
return return
} }
defer resp.Body.Close() defer resp.Body.Close()
doc, err := goquery.NewDocumentFromReader(resp.Body) doc, err := goquery.NewDocumentFromReader(resp.Body)
if err != nil { if err != nil {
fmt.Println("parse doc err ", err)
return return
} }
@ -68,10 +72,12 @@ func getPageHTML(page *model.FacebookPage) {
timeEl := s.Find("abbr") timeEl := s.Find("abbr")
time, timeExists := timeEl.Attr("data-utime") time, timeExists := timeEl.Attr("data-utime")
if !timeExists { if !timeExists {
fmt.Println("time not found")
return return
} }
link, linkExists := timeEl.Parent().Attr("href") link, linkExists := timeEl.Parent().Attr("href")
if !linkExists { if !linkExists {
fmt.Println("link not found")
return return
} }
postContent := s.Find("div.userContent") postContent := s.Find("div.userContent")
@ -88,6 +94,7 @@ func getPageHTML(page *model.FacebookPage) {
} }
} }
if !idFlag { if !idFlag {
fmt.Println("id not found")
return return
} }
} }
@ -96,6 +103,7 @@ func getPageHTML(page *model.FacebookPage) {
timeInt, err := strconv.ParseInt(time, 10, 32) timeInt, err := strconv.ParseInt(time, 10, 32)
if err != nil { if err != nil {
fmt.Println("time parse err ", err)
return return
} }