-
Notifications
You must be signed in to change notification settings - Fork 0
/
inspect.go
70 lines (59 loc) · 1.29 KB
/
inspect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"clout/models"
"clout/network"
"encoding/json"
"fmt"
"os"
"strings"
"time"
"github.com/webview/webview"
)
func HandleInspect() {
if len(os.Args) < 3 {
fmt.Println("username")
return
}
username := os.Args[2]
if argMap["scrape"] != "" {
js := network.GetSingleProfile(username)
var sp models.SingleProfile
json.Unmarshal([]byte(js), &sp)
tokens := strings.Split(sp.Profile.Description, "\n")
for _, token := range tokens {
tokens = strings.Split(token, " ")
for _, token := range tokens {
fmt.Println(token)
if strings.Contains(token, "twitter.com/") {
HandleTwitterGrab(token)
}
}
}
return
}
GuiShowNotifications(username)
}
var w webview.WebView
func HandleTwitterGrab(url string) {
debug := true
w = webview.New(debug)
w.SetTitle("cloutcli")
w.SetSize(800, 600, webview.HintNone)
w.Navigate(url)
w.Bind("sendBackBodyInnerHTML", twitterCallback)
w.Dispatch(func() {
go func() {
time.Sleep(time.Second * 4)
w.Eval("sendBackBodyInnerHTML(document.body.innerHTML);")
}()
})
w.Run()
}
func twitterCallback(data string) {
tokens := strings.Split(data, "followers")
tokens = strings.Split(tokens[1], ">")
tokens = strings.Split(tokens[3], "<")
fmt.Println("followers:", tokens[0])
w.Terminate()
//w.Destroy()
}