fix: 提交答案时出现滑块的问题,昨完一个项目后会关闭当前tab
This commit is contained in:
parent
e6c80e8567
commit
024568d5de
|
@ -24,6 +24,7 @@ import (
|
||||||
"github.com/mxschmitt/playwright-go"
|
"github.com/mxschmitt/playwright-go"
|
||||||
"github.com/nfnt/resize"
|
"github.com/nfnt/resize"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
goqrcode "github.com/skip2/go-qrcode"
|
||||||
"golang.org/x/image/bmp"
|
"golang.org/x/image/bmp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -111,6 +112,14 @@ func (c *Core) L() ([]Cookie, error) {
|
||||||
log.Infoln(g.Result)
|
log.Infoln(g.Result)
|
||||||
codeURL := fmt.Sprintf("https://login.xuexi.cn/login/qrcommit?showmenu=false&code=%v&appId=dingoankubyrfkttorhpou", g.Result)
|
codeURL := fmt.Sprintf("https://login.xuexi.cn/login/qrcommit?showmenu=false&code=%v&appId=dingoankubyrfkttorhpou", g.Result)
|
||||||
|
|
||||||
|
err = goqrcode.WriteFile(codeURL, goqrcode.Medium, 128, "qrcode.png")
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("图片生成错误" + err.Error())
|
||||||
|
err = nil
|
||||||
|
} else {
|
||||||
|
log.Infoln("二维码已生成到目录下的qrcode.png")
|
||||||
|
}
|
||||||
|
|
||||||
qrCodeString := qrcodeTerminal.New2(qrcodeTerminal.ConsoleColors.BrightBlack, qrcodeTerminal.ConsoleColors.BrightWhite, qrcodeTerminal.QRCodeRecoveryLevels.Low).Get(codeURL)
|
qrCodeString := qrcodeTerminal.New2(qrcodeTerminal.ConsoleColors.BrightBlack, qrcodeTerminal.ConsoleColors.BrightWhite, qrcodeTerminal.QRCodeRecoveryLevels.Low).Get(codeURL)
|
||||||
qrCodeString.Print()
|
qrCodeString.Print()
|
||||||
c.Push("text", "https://johlanse.github.io/study_xxqg/scheme.html?"+url.QueryEscape(codeURL))
|
c.Push("text", "https://johlanse.github.io/study_xxqg/scheme.html?"+url.QueryEscape(codeURL))
|
||||||
|
|
|
@ -48,6 +48,9 @@ func (c *Core) RespondDaily(cookies []Cookie, model string) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
page.Close()
|
||||||
|
}()
|
||||||
page.Goto("https://pc.xuexi.cn/points/my-points.html")
|
page.Goto("https://pc.xuexi.cn/points/my-points.html")
|
||||||
err = (*c.context).AddCookies(cookieToParam(cookies)...)
|
err = (*c.context).AddCookies(cookieToParam(cookies)...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -160,9 +163,15 @@ func (c *Core) RespondDaily(cookies []Cookie, model string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if en {
|
if en {
|
||||||
|
page.Mouse().Move(496, 422)
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
page.Mouse().Down()
|
||||||
|
|
||||||
|
page.Mouse().Move(772, 416, playwright.MouseMoveOptions{})
|
||||||
|
page.Mouse().Up()
|
||||||
|
time.Sleep(10 * time.Second)
|
||||||
log.Infoln("可能存在滑块")
|
log.Infoln("可能存在滑块")
|
||||||
c.Push("text", "答题过程出现滑块")
|
c.Push("text", "答题过程出现滑块,正在尝试滑动")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch model {
|
switch model {
|
||||||
|
|
|
@ -116,6 +116,9 @@ func (c *Core) LearnArticle(cookies []Cookie) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
page.Close()
|
||||||
|
}()
|
||||||
|
|
||||||
err = (*c.context).AddCookies(cookieToParam(cookies)...)
|
err = (*c.context).AddCookies(cookieToParam(cookies)...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -208,7 +211,9 @@ func (c *Core) LearnVideo(cookies []Cookie) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
page.Close()
|
||||||
|
}()
|
||||||
var resp string
|
var resp string
|
||||||
err = gout.GET("http://1.15.144.22/stealth.min.js").BindBody(&resp).Do()
|
err = gout.GET("http://1.15.144.22/stealth.min.js").BindBody(&resp).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -21,6 +21,7 @@ func cookieToJar(cookies []Cookie) []*http.Cookie {
|
||||||
Domain: c.Domain,
|
Domain: c.Domain,
|
||||||
Secure: c.Secure,
|
Secure: c.Secure,
|
||||||
HttpOnly: c.HTTPOnly,
|
HttpOnly: c.HTTPOnly,
|
||||||
|
SameSite: http.SameSiteDefaultMode,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
10
main.go
10
main.go
|
@ -37,6 +37,16 @@ func init() {
|
||||||
log.SetLevel(level)
|
log.SetLevel(level)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
pid := os.Getpid()
|
||||||
|
pi := strconv.Itoa(pid)
|
||||||
|
err := os.WriteFile("pid.pid", []byte(pi), 0666)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("pid写入失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
config lib.Config
|
config lib.Config
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue