forked from wxkeykey/HiFiNi-Auto-Sign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (41 loc) · 894 Bytes
/
main.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
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
)
func main() {
client := &http.Client{}
success := SignIn(client)
if success {
fmt.Println("签到成功")
} else {
fmt.Println("签到失败")
os.Exit(3)
}
}
// SignIn 签到
func SignIn(client *http.Client) bool {
//生成要访问的url
url := "https://www.hifini.com/sg_sign.htm"
cookie := os.Getenv("COOKIE")
if cookie == "" {
fmt.Println("COOKIE不存在,请检查是否添加")
return false
}
//提交请求
reqest, err := http.NewRequest("POST", url, nil)
reqest.Header.Add("Cookie", cookie)
reqest.Header.Add("x-requested-with", "XMLHttpRequest")
//处理返回结果
response, err := client.Do(reqest)
if err != nil {
panic(err)
}
defer response.Body.Close()
buf, _ := ioutil.ReadAll(response.Body)
fmt.Println(string(buf))
return strings.Contains(string(buf), "成功")
}