To avoid mark as duplicate then I put some source where I've read :
- Python and Selenium - Reboot program and reuse same browser session
- Python and Selenium - Reuse a whatsapp web session
Currently I want to make python selenium application so that it could send my message to my customer. On those 2 articles on above say if possible to use local storage to keep logged in into web.whatsapp.com after scan qr-code once.
this is my code :
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
import sys
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)
This code worked well, so I can open web.whatsapp.com with login at once, and then use it to send message.
Q : Is possible to save whatsapp session from chrome local storage to database eg : mysql or etc so that I can use it to make whatsapp web keep logged in although with different device / computer.
In other word is possible to change the value of :
user-data-dir=C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data
with the value of web.whatsapp.com session that stored in my database?
Note : if not possible, please tell me another solution so that I still can use it to access whatsapp account in another device without copy user data folder and then move to new device.
Thanks