fix group read
This commit is contained in:
parent
d6af7b3ccb
commit
cd877b21e3
@ -62,7 +62,8 @@ func (p *FacebookPage) GetGroups() (err error) {
|
|||||||
left join "public"."line_group" g
|
left join "public"."line_group" g
|
||||||
on g.id = rt."line"
|
on g.id = rt."line"
|
||||||
where
|
where
|
||||||
p.id = $1`
|
p.id = $1
|
||||||
|
and rt.facebook is not null`
|
||||||
err = x.Select(&p.Groups, query, p.ID)
|
err = x.Select(&p.Groups, query, p.ID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,8 @@ func (p *TwitchChannel) GetGroups() (err error) {
|
|||||||
left join "public"."line_group" g
|
left join "public"."line_group" g
|
||||||
on g.id = rt.line
|
on g.id = rt.line
|
||||||
where
|
where
|
||||||
tw.id = $1`
|
tw.id = $1
|
||||||
|
and rt.twitch is not null`
|
||||||
err = x.Select(&p.Groups, query, p.ID)
|
err = x.Select(&p.Groups, query, p.ID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,8 @@ func (p *YoutubeChannel) GetGroups() (err error) {
|
|||||||
left join "public"."line_group" g
|
left join "public"."line_group" g
|
||||||
on g.id = rt.line
|
on g.id = rt.line
|
||||||
where
|
where
|
||||||
yt.id = $1`
|
yt.id = $1
|
||||||
|
and rt.youtube is not null`
|
||||||
err = x.Select(&p.Groups, query, p.ID)
|
err = x.Select(&p.Groups, query, p.ID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ var c *cron.Cron
|
|||||||
// SetBackground -
|
// SetBackground -
|
||||||
func SetBackground() {
|
func SetBackground() {
|
||||||
c = cron.New()
|
c = cron.New()
|
||||||
c.AddFunc("0 * * * * *", readFacebookPage)
|
// c.AddFunc("0 * * * * *", readFacebookPage)
|
||||||
c.AddFunc("*/20 * * * * *", getStreamStatus)
|
c.AddFunc("*/20 * * * * *", getStreamStatus)
|
||||||
c.AddFunc("*/5 * * * * *", checkOpay)
|
c.AddFunc("*/5 * * * * *", checkOpay)
|
||||||
c.AddFunc("0 0 */3 * * *", checkYoutubeSubscribe)
|
c.AddFunc("0 0 */3 * * *", checkYoutubeSubscribe)
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
package background
|
package background
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -53,45 +49,26 @@ func readFacebookPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getPageHTML(page *model.FacebookPage) {
|
func getPageHTML(page *model.FacebookPage) {
|
||||||
fmt.Println("run page ::::: ", page.ID)
|
|
||||||
err := page.GetGroups()
|
err := page.GetGroups()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("get page group err ", err)
|
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://facebook.com/%s", page.ID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("get page html err ", err)
|
fmt.Println("get page html err ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
doc, err := goquery.NewDocumentFromReader(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
|
||||||
sel := doc.Find("div.userContentWrapper")
|
sel := doc.Find("div.userContentWrapper")
|
||||||
fmt.Println("select element length >>>>> ", sel.Length())
|
|
||||||
sel.Each(func(idx int, s *goquery.Selection) {
|
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")
|
||||||
@ -122,7 +99,7 @@ func getPageHTML(page *model.FacebookPage) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fmt.Printf("Time: %s / Text: %s / ID: %s \n", time, text, postID)
|
fmt.Printf("Time: %s / Text: %s / ID: %s \n", time, text, postID)
|
||||||
|
|
||||||
timeInt, err := strconv.ParseInt(time, 10, 32)
|
timeInt, err := strconv.ParseInt(time, 10, 32)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user