fix: fix
This commit is contained in:
@@ -202,21 +202,18 @@ func findCommentElement(page *rod.Page, commentID, userID string) (*rod.Element,
|
|||||||
// === 4. 先滚动到最后一个评论(触发懒加载)===
|
// === 4. 先滚动到最后一个评论(触发懒加载)===
|
||||||
if currentCount > 0 {
|
if currentCount > 0 {
|
||||||
logrus.Infof("滚动到最后一个评论(共 %d 条)", currentCount)
|
logrus.Infof("滚动到最后一个评论(共 %d 条)", currentCount)
|
||||||
_, err := page.Eval(`() => {
|
|
||||||
const container = document.querySelector('.comments-container');
|
// 使用 Go 获取所有评论元素
|
||||||
if (!container) return false;
|
elements, err := page.Timeout(2 * time.Second).Elements(".parent-comment, .comment-item, .comment")
|
||||||
|
if err == nil && len(elements) > 0 {
|
||||||
// 查找最后一个评论
|
// 滚动到最后一个评论
|
||||||
const comments = container.querySelectorAll('.parent-comment, .comment-item, .comment');
|
lastComment := elements[len(elements)-1]
|
||||||
if (comments.length > 0) {
|
err := lastComment.ScrollIntoView()
|
||||||
const lastComment = comments[comments.length - 1];
|
if err != nil {
|
||||||
lastComment.scrollIntoView({behavior: 'smooth', block: 'center'});
|
logrus.Warnf("滚动到最后一个评论失败: %v", err)
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
} else {
|
||||||
}`)
|
logrus.Warnf("未找到评论元素: %v", err)
|
||||||
if err != nil {
|
|
||||||
logrus.Warnf("滚动到最后一个评论失败: %v", err)
|
|
||||||
}
|
}
|
||||||
time.Sleep(300 * time.Millisecond)
|
time.Sleep(300 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user