My expectation was something would get added to the cookeies array automatically after validation but that isn't the case.
driver = webdriver.Chrome(chromedriver)
whatsapp_url = "https://web.whatsapp.com"
driver.get(whatsapp_url)
print(driver.get_cookies())
time.sleep(30) # We are doing the manual QR code verification here
print(driver.get_cookies())
driver.get_cookies()
is empty before and after as well
Try this:
options = webdriver.ChromeOptions();
options.add_argument('--user-data-dir=./User_Data')
driver = webdriver.Chrome(chrome_options=options)
driver.get('https://web.whatsapp.com/')
You need to login first time. It'll work always when you have to store your session. No need to import/export cookies.
I couldn't comment Abhi Bhalgami answer but I need to made some changes based on another post:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chromepath = r'E:\chromedriver\chromedriver.exe'
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data")
driver = webdriver.Chrome(executable_path=chromepath, chrome_options=options)
extract and save whatsapp session from chrome browser local storage and then use it on another device
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With