-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkbucks.go
79 lines (60 loc) · 1.79 KB
/
linkbucks.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
71
72
73
74
75
76
77
78
79
package ungo
import (
"encoding/json"
"errors"
"io"
"net/http/cookiejar"
"regexp"
"strconv"
"strings"
"time"
)
const (
baseUrlIntermission = "/intermission/loadTargetUrl?t="
)
func Linkbucks(url string) (string, error) {
for i := 0; ; i++ {
cookie, _ := cookiejar.New(nil)
HH.Referer = "linkbucks.com"
HH.Host = ""
html := htmlDownload(url, cookie)
urlSite := regexp.MustCompile("AdPopUrl: '(.*)'")
urlSite2 := regexp.MustCompile("(http://.*?)/")
tokenUser := regexp.MustCompile("Token: '(.*)'")
adUrl := regexp.MustCompile(" AdUrl: '(.*)'")
aK := regexp.MustCompile("params\\['Au' \\+ 'thKey'\\] = (.*);")
resultUrl := urlSite.FindAllStringSubmatch(html.Html, -1)[0:]
resultUrlS2 := urlSite2.FindAllStringSubmatch(resultUrl[0][1], -1)[0:]
resultToken := tokenUser.FindAllStringSubmatch(html.Html, -1)[0:]
resutladUrl := adUrl.FindAllStringSubmatch(html.Html, -1)[0:]
resultaK := aK.FindAllStringSubmatch(html.Html, -1)[0:]
akMid, err := strconv.Atoi(resultaK[0][1][2:][:6])
if err != nil {
return "", errors.New("Could not parse the linkbucks authentication key.")
}
akNew := resultaK[0][1][:2] + strconv.Itoa(akMid+25) + resultaK[0][1][8:]
HH.Host = strings.Replace(resultUrlS2[0][1], "http://www.", "", -1)
htmlAdUrl := htmlDownload(resutladUrl[0][1], html.Jar)
_ = htmlAdUrl
time.Sleep(5 * time.Second)
htmlIntermission := htmlDownload(resultUrlS2[0][1]+baseUrlIntermission+resultToken[0][1]+"&aK="+akNew+"&a_b=false", html.Jar)
dec := json.NewDecoder(strings.NewReader(htmlIntermission.Html))
for {
err := dec.Decode(&Rj)
if err == io.EOF {
break
} else if err != nil {
return "", err
}
}
if Rj.AdBlockSpotted == true {
continue
}
if Rj.Success == false {
continue
} else {
break
}
}
return Rj.Url, nil
}