diff --git a/module/background/facebook.go b/module/background/facebook.go index 314b7e8..57f7f8c 100644 --- a/module/background/facebook.go +++ b/module/background/facebook.go @@ -1,8 +1,12 @@ package background import ( + "bytes" "fmt" + "io" + "io/ioutil" "net/http" + "os" "regexp" "sort" "strconv" @@ -62,14 +66,33 @@ func getPageHTML(page *model.FacebookPage) { return } defer resp.Body.Close() - doc, err := goquery.NewDocumentFromReader(resp.Body) + + body, err := ioutil.ReadAll(resp.Body) + + fmt.Print("StatusCode:", resp.StatusCode) + fmt.Println(" ", resp.Request.URL) + + fmt.Println("page size ::::::: ", len(body)) + + rrr := bytes.NewReader(body) + f, err := os.Create("/tmp/" + page.ID + ".html") + if err == nil { + io.Copy(f, rrr) + f.Close() + rrr.Seek(0, 0) + } + + doc, err := goquery.NewDocumentFromReader(rrr) if err != nil { fmt.Println("parse doc err ", err) return } + body = nil var pageData []*PageData - doc.Find("div.userContentWrapper").Each(func(idx int, s *goquery.Selection) { + sel := doc.Find("div.userContentWrapper") + fmt.Println("select element length >>>>> ", sel.Length()) + sel.Each(func(idx int, s *goquery.Selection) { timeEl := s.Find("abbr") time, timeExists := timeEl.Attr("data-utime") if !timeExists { diff --git a/module/twitch-irc/twitch-irc.go b/module/twitch-irc/twitch-irc.go index cfb3b29..b3f83c6 100644 --- a/module/twitch-irc/twitch-irc.go +++ b/module/twitch-irc/twitch-irc.go @@ -179,6 +179,7 @@ func ircHandle(c *irc.Client, m *irc.Message) { m.Params[0], }, } + fmt.Println("< ", tmp.String()) client.WriteMessage(tmp) } }