Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login session/cookies/user data retention #1148

Closed
hankmoody1 opened this issue Sep 7, 2022 · 3 comments
Closed

Login session/cookies/user data retention #1148

hankmoody1 opened this issue Sep 7, 2022 · 3 comments

Comments

@hankmoody1
Copy link

What versions are you running?

$ go list -m github.com/chromedp/chromedp
github.com/chromedp/chromedp v0.8.5
$ google-chrome --version
Version 104.0.5112.101 (Official Build) (x86_64)
$ go version
go version go1.19 darwin/amd64

What did you do? Include clear steps.

The site Im trying to scrape asks to sign in and then confirm phone number. This happens every time I start scraping.

put your source code here

What did you expect to see?

I expect it to retain login session/cookies/user data so that I dont need to sign in or verify my phone number again.

What did you see instead?

It asks chromedp to sign in again.

I want to avoid this by retaining whatever session/cookies/user data. Can you please tell me how do I do this? I want to avoid this by retaining whatever session/cookies/user data. Can you please tell me how do I do this?

@ZekeLu
Copy link
Member

ZekeLu commented Sep 7, 2022

See #818

@hankmoody1
Copy link
Author

hankmoody1 commented Sep 8, 2022

I saw that question before but I was not sure whether chromedp's default behaviour is to save cookies/session/user data even after closing the program?

@ZekeLu
Copy link
Member

ZekeLu commented Sep 9, 2022

As shown in #818, you have to do two things to persistent user data:

  1. Use chromedp.UserDataDir to specify the directory to store/restore the user data. If you don't do this, chromedp will store the data to a temporary directory and remove the directory after the brower exits.
  2. Call chromedp.Cancel to gracefully close the browser so that the browser has the time to save any unsaved user data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants