fix: fix bug

This commit is contained in:
johlanse 2021-12-10 16:05:03 +08:00
parent f1b1e2c63b
commit 31dd48bdf8
5 changed files with 34 additions and 2 deletions

View File

@ -12,6 +12,7 @@
+ [Windows使用](./docs/windows/index.md) + [Windows使用](./docs/windows/index.md)
+ [Linux使用](./docs/linux/index.md) + [Linux使用](./docs/linux/index.md)
+ [~~源码运行~~](./docs/custom/index.md)
## 申明,该项目仅用于学习。 ## 申明,该项目仅用于学习。

20
docs/custom/index.md Normal file
View File

@ -0,0 +1,20 @@
## 源码运行
### 安装golang环境
+ 去golang[官网](https://studygolang.com/dl) 下载对应系统的安装包建议安装golang 1.7+
+ 配置环境变量
+ 具体可百度搜索golang环境安装
+ 验证,任意终端中输入```go version```,显示版本信息即安装完成
### 运行项目
+ 再任意终端输入一下命令
```yaml
cd study_xxqg
go mod tidy
go build ./
./study_xxqg
```

View File

@ -162,7 +162,10 @@ func (c *Core) Login() ([]Cookie, error) {
var result []byte var result []byte
buffer := bytes.NewBuffer(result) buffer := bytes.NewBuffer(result)
_ = Clip(bytes.NewReader(screen), buffer, 0, 0, 525, 35, 755, 255, 0) //os.WriteFile("screen1.png", screen, 0666)
//_ = Clip(bytes.NewReader(screen), buffer, 0, 0, 525, 35, 755, 255, 0)
_ = Clip(bytes.NewReader(screen), buffer, 0, 0, 529, 70, 748, 284, 0)
c.Push("markdown", fmt.Sprintf("![screenshot](%v) \n>点开查看登录二维码\n>请在五分钟内完成扫码", "data:image/png;base64,"+base64.StdEncoding.EncodeToString(buffer.Bytes()))) c.Push("markdown", fmt.Sprintf("![screenshot](%v) \n>点开查看登录二维码\n>请在五分钟内完成扫码", "data:image/png;base64,"+base64.StdEncoding.EncodeToString(buffer.Bytes())))
c.Push("image", base64.StdEncoding.EncodeToString(buffer.Bytes())) c.Push("image", base64.StdEncoding.EncodeToString(buffer.Bytes()))
os.WriteFile("screen.png", buffer.Bytes(), 0666) os.WriteFile("screen.png", buffer.Bytes(), 0666)
@ -226,6 +229,7 @@ func removeNode(page playwright.Page) {
page.Evaluate(`document.getElementsByClassName("layout-footer")[0].remove()`) //nolint:errcheck page.Evaluate(`document.getElementsByClassName("layout-footer")[0].remove()`) //nolint:errcheck
page.Evaluate(`document.getElementsByClassName("redflag-2")[0].remove()`) //nolint:errcheck page.Evaluate(`document.getElementsByClassName("redflag-2")[0].remove()`) //nolint:errcheck
page.Evaluate(`document.getElementsByClassName("ddlogintext")[0].remove()`) //nolint:errcheck page.Evaluate(`document.getElementsByClassName("ddlogintext")[0].remove()`) //nolint:errcheck
page.Evaluate(`document.getElementsByClassName("oath")[0].remove()`)
} }
// Clip // Clip

View File

@ -116,6 +116,7 @@ func (c *Core) LearnArticle(cookies []Cookie) {
log.Errorln("添加cookie失败" + err.Error()) log.Errorln("添加cookie失败" + err.Error())
return return
} }
tryCount := 0 tryCount := 0
for { for {

View File

@ -12,6 +12,7 @@ func cookieToJar(cookies []Cookie) []*http.Cookie {
) )
for _, c := range cookies { for _, c := range cookies {
cooks = append( cooks = append(
cooks, cooks,
&http.Cookie{ &http.Cookie{
Name: c.Name, Name: c.Name,
@ -30,11 +31,16 @@ func cookieToParam(cookies []Cookie) []playwright.SetNetworkCookieParam {
var ( var (
cooks []playwright.SetNetworkCookieParam cooks []playwright.SetNetworkCookieParam
) )
for _, c := range cookies { for _, c := range cookies {
domain := ".xuexi.cn"
if c.Name == "acw_tc" || c.Name == "aliyungf_tc" {
domain = "iflow-api.xuexi.cn\t"
}
cooks = append(cooks, playwright.SetNetworkCookieParam{ cooks = append(cooks, playwright.SetNetworkCookieParam{
Name: c.Name, Name: c.Name,
Value: c.Value, Value: c.Value,
Domain: playwright.String(c.Domain), Domain: playwright.String(domain),
Path: playwright.String(c.Path), Path: playwright.String(c.Path),
Expires: playwright.Int(c.Expires), Expires: playwright.Int(c.Expires),
HttpOnly: playwright.Bool(c.HTTPOnly), HttpOnly: playwright.Bool(c.HTTPOnly),