From 20dfdec93dba0eb4ba1187a032296a09b1feaa4e Mon Sep 17 00:00:00 2001 From: I Luk Kim Date: Tue, 11 Apr 2023 19:33:31 +0900 Subject: [PATCH] update --- bingauto2.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bingauto2.js b/bingauto2.js index 15c1027..4f4153a 100755 --- a/bingauto2.js +++ b/bingauto2.js @@ -463,6 +463,7 @@ module.exports = class BingAuto2 { for (let i = 0; i < searchCnt; i++) { try { console.log(`Search ${i + 1}/${searchCnt} : ${keywords[i]}`); + await page.waitForSelector('#sb_form_q'); let searchBar = await page.$('#sb_form_q'); // clear await searchBar.click({clickCount: 3}); @@ -502,9 +503,12 @@ module.exports = class BingAuto2 { async doAllSearch() { let searchStatus = await this.checkSearchStatus(); console.log('> Search status:', searchStatus); + let point_per_search = 5; + if (Object.keys(searchStatus).length === 2) + point_per_search = 3; for (let searchType in searchStatus) { - let searchCnt = Math.floor((searchStatus[searchType][1] - searchStatus[searchType][0]) / 5); + let searchCnt = Math.floor((searchStatus[searchType][1] - searchStatus[searchType][0]) / point_per_search); if (searchCnt !== 0) { console.log('>', searchType, 'search'); let page = await this.newPage(searchType);