await new Promise(resolve => setTimeout(resolve, 2000));
实现每次循环都等待2秒
- async function nextPage() {
- while (true) {
- chocie();
- let next_li = document.querySelector('li[ng-if="directionLinks"][class="ng-scope"]:last-child');
- if (next_li == null){
- break;
- }
- let next_page = next_li.querySelector("a")
- next_page.click();
- await new Promise(resolve => setTimeout(resolve, 2000));
- }
- }
-
- function chocie(){
- console.log("执行具体的操作")
- }
-
- nextPage();