From 678bc71ae0c7bc75b88458af5fb730340d203395 Mon Sep 17 00:00:00 2001 From: zy Date: Sat, 4 Oct 2025 21:14:47 +0800 Subject: [PATCH] =?UTF-8?q?publish:=20=E5=A2=9E=E5=8A=A0=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=BC=B9=E7=AA=97=E7=9A=84=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=20(#201)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * publish: 增加发布移除弹窗的操作 * 随机点击操作 * 更新点击的随机坐标 --- xiaohongshu/publish.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xiaohongshu/publish.go b/xiaohongshu/publish.go index 21eb26a..1cf126f 100644 --- a/xiaohongshu/publish.go +++ b/xiaohongshu/publish.go @@ -3,6 +3,7 @@ package xiaohongshu import ( "context" "log/slog" + "math/rand" "os" "strings" "time" @@ -66,15 +67,24 @@ func (p *PublishAction) Publish(ctx context.Context, content PublishImageContent func removePopCover(page *rod.Page) { + // 先移除弹窗封面 has, elem, err := page.Has("div.d-popover") if err != nil { return } - if has { 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 {