-
Notifications
You must be signed in to change notification settings - Fork 0
/
lotterySession.go
60 lines (55 loc) · 1.92 KB
/
lotterySession.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
package goLotteryTw
import (
"net/url"
"github.com/PuerkitoBio/goquery"
)
type LotterySession struct {
lastEventTarget string
lastEventArgument string
lastLastFocus string
lastViewState string
lastViewStateGenerator string
lastViewStateEncrypted string
lastEventValidation string
}
func (ls *LotterySession) getDefaultValues() url.Values {
values := make(url.Values)
values.Set("__EVENTTARGET", ls.lastEventTarget)
values.Set("__EVENTARGUMENT", ls.lastEventArgument)
values.Set("__LASTFOCUS", ls.lastLastFocus)
values.Set("__VIEWSTATE", ls.lastViewState)
values.Set("__VIEWSTATEGENERATOR", ls.lastViewStateGenerator)
values.Set("__VIEWSTATEENCRYPTED", ls.lastViewStateEncrypted)
values.Set("__EVENTVALIDATION", ls.lastEventValidation)
return values
}
func (ls *LotterySession) RefreshForm(doc *goquery.Document) {
newEventTarget, existEventTarget := doc.Find("#__EVENTTARGET").Attr("value")
newEventArgument, existEventArgument := doc.Find("#__EVENTARGUMENT").Attr("value")
newLastFocus, existLastFocus := doc.Find("#__LASTFOCUS").Attr("value")
newViewState, existViewState := doc.Find("#__VIEWSTATE").Attr("value")
newViewStateGenerator, existViewStateGenerator := doc.Find("#__VIEWSTATEGENERATOR").Attr("value")
newViewStateEncrypted, existViewStateEncrypted := doc.Find("#__VIEWSTATEENCRYPTED").Attr("value")
newEventValidation, existEventValidation := doc.Find("#__EVENTVALIDATION").Attr("value")
if existEventTarget {
ls.lastEventTarget = newEventTarget
}
if existEventArgument {
ls.lastEventArgument = newEventArgument
}
if existLastFocus {
ls.lastLastFocus = newLastFocus
}
if existViewState {
ls.lastViewState = newViewState
}
if existViewStateGenerator {
ls.lastViewStateGenerator = newViewStateGenerator
}
if existViewStateEncrypted {
ls.lastViewStateEncrypted = newViewStateEncrypted
}
if existEventValidation {
ls.lastEventValidation = newEventValidation
}
}