-
Hello, assuming I want to access the example.com website, how can I use the cookies of the example.com website before entering it? I won't be visiting any other site before example.com, so I need to add this before starting the Chrome new tab or before the webdriver has initiated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
If you mean from a different session save the cookies to then load them later on you can use the pickle, read this article which should tell you everything you need: https://www.scrapingbee.com/webscraping-questions/selenium/how-to-save-cookies-selenium/ Or do you mean manually 'forcing' cookies to be added to the browser without being on it's domain? |
Beta Was this translation helpful? Give feedback.
-
That's called preloading cookies. You can use the Chrome Devtools Protocol (CDP) for that: driver.execute_cdp_cmd('Network.setCookie', cookie) There's a nice Stack Overflow post about that here: https://stackoverflow.com/a/63220249/7058266 See https://chromedevtools.github.io/devtools-protocol/tot/Network/ for more related CDP methods for that, eg:
|
Beta Was this translation helpful? Give feedback.
That's called preloading cookies. You can use the Chrome Devtools Protocol (CDP) for that:
There's a nice Stack Overflow post about that here: https://stackoverflow.com/a/63220249/7058266
See https://chromedevtools.github.io/devtools-protocol/tot/Network/ for more related CDP methods for that, eg: