This commit is contained in:
Jay 2018-09-21 13:37:39 +08:00
parent 50b0983831
commit d6af7b3ccb
2 changed files with 26 additions and 2 deletions

View File

@ -1,8 +1,12 @@
package background package background
import ( import (
"bytes"
"fmt" "fmt"
"io"
"io/ioutil"
"net/http" "net/http"
"os"
"regexp" "regexp"
"sort" "sort"
"strconv" "strconv"
@ -62,14 +66,33 @@ func getPageHTML(page *model.FacebookPage) {
return return
} }
defer resp.Body.Close() 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 { if err != nil {
fmt.Println("parse doc err ", err) fmt.Println("parse doc err ", err)
return return
} }
body = nil
var pageData []*PageData 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") timeEl := s.Find("abbr")
time, timeExists := timeEl.Attr("data-utime") time, timeExists := timeEl.Attr("data-utime")
if !timeExists { if !timeExists {

View File

@ -179,6 +179,7 @@ func ircHandle(c *irc.Client, m *irc.Message) {
m.Params[0], m.Params[0],
}, },
} }
fmt.Println("< ", tmp.String())
client.WriteMessage(tmp) client.WriteMessage(tmp)
} }
} }