Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
L2ncE committed Jan 14, 2023
1 parent 9fc144f commit 5121330
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
7 changes: 3 additions & 4 deletions grab/grabber.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Grabber struct {
// SingleRob 仅抢课一次,传递单个 load 以及 cookie
func (g *Grabber) SingleRob(cookie, load string) string {
client := &http.Client{}
var data = strings.NewReader(load)
data := strings.NewReader(load)
req, err := http.NewRequest("POST", "http://xk1.cqupt.edu.cn/post.php", data)
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -73,7 +73,7 @@ func (g *Grabber) LoopRob(cookie string, loads []string) {
for j, load := range loads {
j += 1

//调用SingleRob进行循环抢课
// 调用SingleRob进行循环抢课

info := g.SingleRob(cookie, load)
if info == "ok" {
Expand All @@ -94,12 +94,11 @@ ok:
// LoopRobWithCustomTime 循环抢课,支持多个课程同时抢,支持自定义时间。不建议使用
// 传入一个 cookie 和一个 load 切片以及自定义时间
func (g *Grabber) LoopRobWithCustomTime(cookie string, loads []string, duration float64) {

for i := 1; ; i++ {
log.Printf("第%d次抢课开始", i)
for j, load := range loads {
j += 1
//调用SingleRob进行循环抢课
// 调用SingleRob进行循环抢课
info := g.SingleRob(cookie, load)
if info == "ok" {
log.Printf("课程%d:%s\n", j, info)
Expand Down
21 changes: 12 additions & 9 deletions query/queryer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (
"github.com/LgoLgo/cqupt-grabber/model"
)

type Queryer struct {
}
type Queryer struct{}

func request(str, cookie string) []byte {
client := &http.Client{}
Expand Down Expand Up @@ -56,15 +55,17 @@ func (q *Queryer) AllRenWen(cookie string) {
SRsLimit := strconv.Itoa(item.RsLimit)
SRwType := strconv.Itoa(item.RwType)

var strs = []string{"xnxq=", item.Xnxq, "&jxb=", item.Jxb, "&kchb=", item.Kcbh, "&kcmc=", item.Kcmc,
strs := []string{
"xnxq=", item.Xnxq, "&jxb=", item.Jxb, "&kchb=", item.Kcbh, "&kcmc=", item.Kcmc,
"&xf=", item.Xf, "&teaname=", item.TeaName, "&rslimit=", SRsLimit, "&rwtype=", SRwType, "&kclb=",
item.Kclb, "&kchtye=", item.KchType, "&memo=", item.Memo}
item.Kclb, "&kchtye=", item.KchType, "&memo=", item.Memo,
}

for _, str := range strs {
builder.WriteString(str)
}
loads := builder.String()
err = ioutil.WriteFile("./output_renwen.txt", []byte(loads), 0666) //写入文件(字节数组)
err = ioutil.WriteFile("./output_renwen.txt", []byte(loads), 0o666) // 写入文件(字节数组)
if err != nil {
log.Fatal(err.Error())
}
Expand All @@ -84,15 +85,17 @@ func (q *Queryer) AllZiRan(cookie string) {
SRsLimit := strconv.Itoa(item.RsLimit)
SRwType := strconv.Itoa(item.RwType)

var strs = []string{"xnxq=", item.Xnxq, "&jxb=", item.Jxb, "&kchb=", item.Kcbh, "&kcmc=", item.Kcmc, "&xf=",
strs := []string{
"xnxq=", item.Xnxq, "&jxb=", item.Jxb, "&kchb=", item.Kcbh, "&kcmc=", item.Kcmc, "&xf=",
item.Xf, "&teaname=", item.TeaName, "&rslimit=", SRsLimit, "&rwtype=", SRwType, "&kclb=", item.Kclb,
"&kchtye=", item.KchType, "&memo=", item.Memo}
"&kchtye=", item.KchType, "&memo=", item.Memo,
}

for _, str := range strs {
builder.WriteString(str)
}
loads := builder.String()
err = ioutil.WriteFile("./output_ziran.txt", []byte(loads), 0666) //写入文件(字节数组)
err = ioutil.WriteFile("./output_ziran.txt", []byte(loads), 0o666) // 写入文件(字节数组)
if err != nil {
log.Fatal(err.Error())
}
Expand All @@ -114,7 +117,7 @@ func (q *Queryer) Search(param, cookie, content string) {
SRsLimit := strconv.Itoa(item.RsLimit)
SRwType := strconv.Itoa(item.RwType)

var strs = []string{"xnxq=", item.Xnxq, "&jxb=", item.Jxb, "&kchb=", item.Kcbh, "&kcmc=", item.Kcmc, "&xf=", item.Xf, "&teaname=", item.TeaName, "&rslimit=", SRsLimit, "&rwtype=", SRwType, "&kclb=", item.Kclb, "&kchtye=", item.KchType, "&memo=", item.Memo}
strs := []string{"xnxq=", item.Xnxq, "&jxb=", item.Jxb, "&kchb=", item.Kcbh, "&kcmc=", item.Kcmc, "&xf=", item.Xf, "&teaname=", item.TeaName, "&rslimit=", SRsLimit, "&rwtype=", SRwType, "&kclb=", item.Kclb, "&kchtye=", item.KchType, "&memo=", item.Memo}
for _, str := range strs {
builder.WriteString(str)
}
Expand Down

0 comments on commit 5121330

Please sign in to comment.