gpt4 book ai didi

javascript - 如何在 Node 上进行 Nightmare 般的条件循环点击事件?

转载 作者:行者123 更新时间:2023-12-03 13:24:00 25 4
gpt4 key购买 nike

我想使网络爬行器。
所以我正在使用 Node + Nightmare 。

我要抓取的网页具有“加载更多”按钮。
当我单击此按钮时,将像其他任何网页一样加载更多帖子。

问题是-此页面上的帖子数量可以更改。因此,我的搜寻器应用程序不知道按下“加载更多”按钮的次数。

我知道梦night中有一个“存在的” apu,但是我想在有条件的情况下重复使用它,而不是一次或固定次数的循环。

我可以在这种情况下使用任何逻辑吗?
有人帮我T_T

最佳答案

你可以看看我的答案Repeatedly Clickling

您可以使用以下相同的代码作为条件:

function next() {
if(condition)
BETHESDA.wait('div[data-is="main-mods-pager"] > button')
.click('div[data-is="main-mods-pager"] > button')
.then(function() {
console.log("click done");
next();
})
.catch(function(err) {
console.log(err);
console.log("All done.");
});
}

function condition() {
//Your condition code goes here
//return true or false
}

我认为这应该是一个重复的问题。

关于javascript - 如何在 Node 上进行 Nightmare 般的条件循环点击事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44623045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com