1

To avoid mark as duplicate then I put some source where I've read :

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

Gumgum
  • 23
  • 1
  • 7

1 Answers1

0

if using linux or mac go to your terminal and type :

chromium --remote-debugging-port=9250

where chromium is the browser and 9250 is a port number which you can choose and then in your selenium file while making a selenium object

opts=Options()
opts.add_experimental_option("debuggerAddress","localhost:9250")
driver=webdriver.Chrome(options=opts)

and this shall open your browser with every websites logged in.