This commit is contained in:
2021-11-02 10:21:36 -05:00
parent 0d2d278260
commit 1ddbca8352

View File

@@ -5,6 +5,8 @@ import (
"encoding/json"
"fmt"
"time"
"github.com/go-rod/rod"
)
type InstaRes struct {
@@ -123,14 +125,18 @@ func (r *Runner) GetIntsaEgagement(urls []string) []InstaPost {
res.URL = "https://www.instagram.com" + url
if res.Timestamp.Before(r.currentTime) {
//Hard get the likes
if res.Likes == 0 {
r.page.MustElementByJS(instagram_liked_by_url).MustClick()
if res.Likes == 0 && res.Views == 0 {
element, err := r.page.ElementByJS(&rod.EvalOptions{JS: instagram_liked_by_url})
if err != nil {
fmt.Println("Edge Case Where Likes and Comments are Zero")
} else {
element.MustClick()
r.page.MustWaitLoad()
r.Scroll(99999, longTimeOut)
likes := r.page.MustEval(instagram_liked_by).Int()
res.Likes = likes
}
}
if res.Views != 0 {
res.Engagement = res.Views + res.Comments