-
Notifications
You must be signed in to change notification settings - Fork 32
/
xzssc.go
63 lines (55 loc) · 1.38 KB
/
xzssc.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
package main
import (
"reflect"
"unsafe"
"fmt"
"io/ioutil"
"regexp"
"strconv"
"time"
"github.com/henrylee2cn/surfer"
)
func Slice(s string) (b []byte) {
pbytes := (*reflect.SliceHeader)(unsafe.Pointer(&b))
pstring := (*reflect.StringHeader)(unsafe.Pointer(&s))
pbytes.Data = pstring.Data
pbytes.Len = pstring.Len
pbytes.Cap = pstring.Len
return
}
func xzssc_xjflcp_com(gameType int, period *string) {
var strPeriod string
slicePeriod := string(Slice(*period))
if len(slicePeriod) == 9 && slicePeriod[6:7] == "0" {
strPeriod = fmt.Sprintf("%s%s", slicePeriod[0:6], slicePeriod[7:9])
} else {
strPeriod = slicePeriod
}
u := fmt.Sprintf("http://www.xjflcp.com/game/sscOpenDetail?gameId=7&lotteryIssue=20%s", strPeriod)
resp, err := surfer.Download(&surfer.Request{
Url: u,
//DownloaderID: 1,
})
if err != nil {
fmt.Println("95:", err)
return
}
defer resp.Body.Close()
defer surfer.DestroyJsFiles()
var b []byte
b, err = ioutil.ReadAll(resp.Body)
re := regexp.MustCompile(`(20)([0-9]{8})([\S\s]*)(<td colspan=.?3.?>)([0-9\ ]{9})(</td>)`).FindAllStringSubmatch(string(b), -1)
if len(re) != 1 || len(re[0]) != 7 {
return
}
if *period != re[0][1] { //期号
return
}
var issue int
issue, err = strconv.Atoi(*period)
if err != nil {
return
}
dt := data{Type: gameType, Time: time.Now(), Data: re[0][5], Issue: issue}
dt.dataIn("xzssc_xjflcp_com", re[0][5])
}