-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.go
More file actions
114 lines (98 loc) · 2.54 KB
/
Copy pathtest.go
File metadata and controls
114 lines (98 loc) · 2.54 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//go:build ignore
// +build ignore
// 测试接受信息
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
)
const (
url1 = "http://vcard.ccnu.edu.cn/index.php/index/index/virtualreport.html"
url2 = "http://vcard.ccnu.edu.cn/index.php/index/index/cardreport.html"
)
func main() {
//StudentId := "2023214557"
//grade := StudentId[:4]
//fmt.Println("StudentId:", grade)
test()
}
func test() {
var buf bytes.Buffer
writer := multipart.NewWriter(&buf)
// 添加表单字段
_ = writer.WriteField("key", "88Gar7ySd4TeT9Q7O510h9Q6e0pacL2lZ3kmMRwxL7zIU0Y27yvD4IDz1EUYRFYp4K129yqy97HJo4XWLMggipTBH8Hxwp%3DOS4jCW9gLV4yfr")
_ = writer.WriteField("start_time", "2024 09")
writer.Close()
// 创建请求
req, err := http.NewRequest("POST", url2, &buf)
if err != nil {
panic(err)
}
// 设置请求头
req.Header.Set("X-Requested-With", "XMLHttpRequest")
req.Header.Set("Content-Type", writer.FormDataContentType())
// 发送请求
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
// 读取响应
body, _ := ioutil.ReadAll(resp.Body)
var response Response
if err := json.Unmarshal([]byte(body), &response); err != nil {
fmt.Println("Error:", err)
}
fmt.Println(response.Data.List)
//fmt.Println(string(body))
}
type Response struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
List []Transaction `json:"list"`
Sql string `json:"sql"`
} `json:"data"`
}
type Transaction struct {
SMT_TIMES string `json:"SMT_TIMES"`
//SMT_INMONEY string `json:"SMT_INMONEY"`
//SMT_OUTMONEY string `json:"SMT_OUTMONEY"`
//MONEY string `json:"MONEY"`
//SMT_DEALDATETIME string `json:"SMT_DEALDATETIME"` //创建时间
SMT_ORG_NAME string `json:"SMT_ORG_NAME"` //窗口
SMT_DEALNAME string `json:"SMT_DEALNAME"` //消费方式
//BeforeMoney string `json:"before_money"`
AfterMoney string `json:"after_money"`
Money string `json:"money"`
}
//{
//"SMT_TIMES": "902",
//"SMT_INMONEY": "2350",
//"SMT_OUTMONEY": "950",
//"MONEY": "-1400",
//"SMT_DEALDATETIME": "2024-09-26 12:04:23",
//"SMT_ORG_NAME": "锅巴饭",
//"SMT_DEALNAME": "消费",
//"before_money": "23.50",
//"after_money": "9.50",
//"money": "-14.00"
//},
//
//{
//"SMT_TIMES": "0",
//"SMT_INMONEY": "1300",
//"SMT_OUTMONEY": "0",
//"MONEY": "-1300",
//"SMT_DEALDATETIME": "2024-09-26 18:21:16",
//"SMT_ORG_NAME": "铁板饭",
//"SMT_DEALNAME": "第三方支付消费",
//"before_money": "13.00",
//"after_money": "0.00",
//"money": "-13.00"
//},