'How to set PuppeteerSharp load own cookies from file?

I would like to keep my session in Puppeteer-Sharp open for next time so I needed to login manually and enter my SMS from google, after I am logged as my YouTube channel and now I need to scrape my data etc...

So next time I open my puppeteer browser I don't like to repeat this login and sms verification etc...so I found the code how to get cookies so I saw there was 16 cookies names and values which after I login to YouTube shows up, now the question is :

  1. How to SAVE this cookies perhaps in .json for better loading
  2. How to LOAD them after next time I open my puppeteer browser

My Code:

    Await page.GoToAsync("https://www.youtube.com/")
*'HERE I have to manually login because I don't know how should I automate the sms from my mobile to get login, else YouTube doesn't allow other way me to login*
    Dim result = Await page.GetCookiesAsync()
    Console.WriteLine(results)

After I get logged I see 16 lines of cookies anyways what is strange is that logininfo name missing when I login to chrome I use there is this value..



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source