0

I'm monitoring a financial website which requires OTP and whatnot.

  1. My issue is, if the puppeteer script breaks, human intervention is required to get through the OTP/2FA again.
  2. Refreshing the page (F5) also causes the site to request for OTP/2FA again. Meaning, page content has to be restored as well, I can't just load a URL with cookies set.

Is there a way to restore/maintain that session in headless chrome when my script breaks/terminates or machine reboots and be able to resume from it?

After some googling, I found this, Puppeteer: how to store a session (including cookies, page state, local storage, etc) and continue later? but its terms are unfamiliar to me and I'm not certain if it is what I'm looking for.

Any ideas? Thank you.

bilogic
  • 449
  • 3
  • 18
  • Your item 2 means that the data you'd need is likely stored in a way you don't have access to. For example, in an isolated variable. There's no way to save the full state of a page. The accepted answer in the question you linked says as much. You're mostly limited to saving/restoring cookies. – Ouroborus Jul 09 '23 at 05:28
  • Ok, i don't think there is anything that special. How it probably works is that, if the main page/frame is loaded, it will clear all cookies, thus, leading to the OTA/2FA page again. Perhaps succinctly, I'm asking, is there a way to inject page contents and navigate from there? – bilogic Jul 10 '23 at 03:05
  • Yes, you can inject custom content. However, that content won't be hooked up to the page's javascript and you're unlikely to be able to hook it up yourself. – Ouroborus Jul 10 '23 at 03:19
  • Maybe a better way to describe what I'm after is, can Chrome save its state like a virtual machine and resume at at a later time – bilogic Jul 11 '23 at 05:26
  • Nope, that's a not a thing. – Ouroborus Jul 11 '23 at 06:44

0 Answers0