forked from a7a2/cp33client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpk10.go
57 lines (51 loc) · 1.22 KB
/
pk10.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
package main
import (
"fmt"
"io/ioutil"
"strconv"
"time"
// "reflect"
"regexp"
"github.com/henrylee2cn/surfer"
)
func pk10_bwlc_net(gameType int, period *string) {
u := fmt.Sprintf("http://www.bwlc.net/")
resp, err := surfer.Download(&surfer.Request{
Url: u,
//DownloaderID: 1,
})
if err != nil {
fmt.Println("pk10_bwlc_net 22:", err)
return
}
defer resp.Body.Close()
defer surfer.DestroyJsFiles()
var b []byte
b, err = ioutil.ReadAll(resp.Body)
if len(b) < 2200 {
return
}
re := regexp.MustCompile(`(<span class="ml10 b red fa f14">)([0-9]{6})(</span>)([.\S\s]+?)(<ul class="dib">)([.\S\s]*?)(</ul>)`).FindAllStringSubmatch(string(b[21000:]), -1)
if len(re) != 1 && len(re[0]) != 7 {
return
}
if *period != re[0][2] { //期号
return
}
reData := regexp.MustCompile(`[0-9]{2}`).FindAllString(re[0][6], -1)
if len(reData) != 10 {
return
}
var strData string //开奖号码
for i := 0; i < len(reData); i++ {
strData = fmt.Sprintf("%s %s", strData, reData[i])
}
strData = strData[1:] //去掉前面的空格
var issue int
issue, err = strconv.Atoi(*period)
if err != nil {
return
}
dt := data{Type: gameType, Time: time.Now(), Data: strData, Issue: issue}
dt.dataIn("pk10_bwlc_net", strData)
}