-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.go
75 lines (63 loc) · 1.9 KB
/
util.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
package main
import (
"fmt"
"github.com/artificerpi/cn12306/api"
)
// TODO consider replace it with template
func printValues(values []string) {
if len(values) != 36 {
return
}
ticket := api.TicketInfo{
StationTrainCode: values[2],
FromStation: values[5],
ToStation: values[6],
StartTime: values[7],
ArriveTime: values[8],
BusinessSeat: values[31],
FirstClassSeat: values[30],
SecondClassSeat: values[29],
AdvancedSleeper: values[20],
SoftSleeper: values[22],
HardSleeper: values[27],
HardSeat: values[28],
StandUp: values[25],
Other: values[32],
Remark: values[0],
}
fmt.Println(ticket.StationTrainCode, ticket.FromStation, ticket.ToStation, ticket.StartTime, ticket.ArriveTime, ticket.BusinessSeat, ticket.FirstClassSeat, ticket.SecondClassSeat,
ticket.AdvancedSleeper, ticket.SoftSleeper, ticket.HardSleeper, ticket.HardSeat, ticket.StandUp, ticket.Other, ticket.Remark)
}
func parseResult(results [][]string) [][]string {
rows := make([][]string, 0)
for _, v := range results {
if len(v) < 32 {
continue
}
// length 36
// fmt.Println(v)
ticket := api.TicketInfo{
StationTrainCode: v[2],
FromStation: v[5],
ToStation: v[6],
StartTime: v[7],
ArriveTime: v[8],
BusinessSeat: v[31],
FirstClassSeat: v[30],
SecondClassSeat: v[29],
AdvancedSleeper: v[20],
SoftSleeper: v[22],
HardSleeper: v[27],
HardSeat: v[28],
StandUp: v[25],
Other: v[32],
Remark: v[0],
}
data := []string{ticket.StationTrainCode, ticket.FromStation, "", ticket.ToStation, ticket.StartTime, "", ticket.ArriveTime, "", ticket.BusinessSeat, ticket.FirstClassSeat, ticket.SecondClassSeat,
ticket.Other}
rows = append(rows, data)
// fmt.Println(data)
}
// fmt.Println(rows)
return rows
}