diff options
author | Emilien Devos <contact@emiliendevos.be> | 2021-10-02 16:02:25 +0200 |
---|---|---|
committer | Emilien Devos <contact@emiliendevos.be> | 2021-10-02 16:02:25 +0200 |
commit | 52a775dbd3daf86ef34affabf7c27a5a13bd8efc (patch) | |
tree | d4ae9f58e339094b6771247b07461b9865058baf | |
parent | 114a598040b8bb97f7b78a563dade021f0ab2512 (diff) |
handle the case where there is an instant response from cloudflare
-rw-r--r-- | index.js | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 => { |