我试图用 python 访问whatsapp web,而不必每次重新启动程序时扫描二维码(因为在我的普通浏览器中我也不必这样做)。但我怎样才能做到这一点呢?告诉 Whatsapp Web 连接到我的手机的数据存储在哪里?当我重新运行代码时,如何保存这些数据并将其发送到浏览器?
我已经尝试过这个,因为有人告诉我我应该保存cookie:
from selenium import webdriver
import time
browser = None
cookies = None
def init():
browser = webdriver.Firefox(executable_path=r"C:/Users/Pascal/Desktop/geckodriver.exe")
browser.get("https://web.whatsapp.com/")
time.sleep(5) # in this time I scanned the QR to see if there are cookies
cookies = browser.get_cookies()
print(len(cookies))
print(cookies)
init()
Run Code Online (Sandbox Code Playgroud)
不幸的是没有cookie..输出是0和[]。我该如何解决这个问题?