forked from a7a2/cp33client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtjssc.go
48 lines (41 loc) · 1000 Bytes
/
tjssc.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
package main
import (
"fmt"
"io/ioutil"
"regexp"
"strconv"
"strings"
"time"
"github.com/henrylee2cn/surfer"
)
func tjssc_icaile_com(gameType int, period *string) {
u := fmt.Sprintf("http://tjssc.icaile.com/?op=jb3&num=30")
resp, err := surfer.Download(&surfer.Request{
Url: u,
//DownloaderID: 1,
})
if err != nil {
fmt.Println("tjssc_icaile_com 21:", err)
return
}
defer resp.Body.Close()
defer surfer.DestroyJsFiles()
var b []byte
b, err = ioutil.ReadAll(resp.Body)
re := regexp.MustCompile(`(20)([0-9]{9})(</td>)([\S\s]+?)(<td>)([,0-9]{9})(</td>)`).FindAllStringSubmatch(string(b), -1)
c := len(re) - 1
if len(re) == 0 || len(re) < c || len(re[c]) != 8 {
return
}
if *period != re[c][2] { //期号
return
}
strData := strings.Replace(re[c][6], ",", " ", -1)
var issue int
issue, err = strconv.Atoi(re[c][2])
if err != nil {
return
}
dt := data{Type: gameType, Time: time.Now(), Data: strData, Issue: issue}
dt.dataIn("tjssc_icaile_com", strData)
}