summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilien Devos <contact@emiliendevos.be>2021-10-02 16:02:25 +0200
committerEmilien Devos <contact@emiliendevos.be>2021-10-02 16:02:25 +0200
commit52a775dbd3daf86ef34affabf7c27a5a13bd8efc (patch)
treed4ae9f58e339094b6771247b07461b9865058baf
parent114a598040b8bb97f7b78a563dade021f0ab2512 (diff)
handle the case where there is an instant response from cloudflare
-rw-r--r--index.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/index.js b/index.js
index a266cd6..98dd889 100644
--- a/index.js
+++ b/index.js
@@ -81,12 +81,13 @@ const responseHeadersToRemove = ["Accept-Ranges", "Content-Length", "Keep-Alive"
responseBody = await response.text();
responseData = await response.buffer();
while (responseBody.includes("cf-browser-verification") && tryCount <= 10) {
- response = await page.waitForNavigation({ timeout: 30000, waitUntil: 'domcontentloaded' });
+ newResponse = await page.waitForNavigation({ timeout: 30000, waitUntil: 'domcontentloaded' });
+ if (newResponse) response = newResponse;
responseBody = await response.text();
responseData = await response.buffer();
tryCount++;
}
- responseHeaders = response.headers();
+ responseHeaders = await response.headers();
const cookies = await page.cookies();
if (cookies)
cookies.forEach(cookie => {