publish: 增加发布移除弹窗的操作 (#201)

* publish: 增加发布移除弹窗的操作

* 随机点击操作

* 更新点击的随机坐标
This commit is contained in:
zy
2025-10-04 21:14:47 +08:00
committed by GitHub
parent 223d9e146b
commit 678bc71ae0

View File

@@ -3,6 +3,7 @@ package xiaohongshu
import ( import (
"context" "context"
"log/slog" "log/slog"
"math/rand"
"os" "os"
"strings" "strings"
"time" "time"
@@ -66,15 +67,24 @@ func (p *PublishAction) Publish(ctx context.Context, content PublishImageContent
func removePopCover(page *rod.Page) { func removePopCover(page *rod.Page) {
// 先移除弹窗封面
has, elem, err := page.Has("div.d-popover") has, elem, err := page.Has("div.d-popover")
if err != nil { if err != nil {
return return
} }
if has { if has {
elem.MustRemove() elem.MustRemove()
} }
// 兜底:点击一下空位置吧
clickEmptyPosition(page) // 点击空位置
}
func clickEmptyPosition(page *rod.Page) {
x := 380 + rand.Intn(100)
y := 20 + rand.Intn(60)
page.Mouse.MustMoveTo(float64(x), float64(y)).MustClick(proto.InputMouseButtonLeft)
logrus.Infof("点击空位置: x=%d, y=%d", x, y)
} }
func mustClickPublishTab(page *rod.Page, tabname string) error { func mustClickPublishTab(page *rod.Page, tabname string) error {