【发布时间】:2020-12-02 15:58:30
【问题描述】:
我一直在努力使用 selenium 制作一个 WhatsApp 机器人,但每次我运行我的代码时,我都必须重新扫描二维码才能输入它。我在 youtube 视频中找到了使用选项的此解决方案,但它不起作用并返回错误 selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
这是我的代码
from selenium import webdriver
import time
if __name__ == '__main__':
options = webdriver.ChromeOptions()
options.add_argument(r'--user-data-dir=C:\Users\Hill\AppData\Local\Google\Chrome\User Data\Default')
options.add_argument(r'--profile-directory=Default')
driver = webdriver.Chrome(executable_path=r'C:\Program Files (x86)\chromedriver.exe', chrome_options=options)
driver.get('https://web.whatsapp.com')
time.sleep(15)
【问题讨论】:
-
如果有帮助请采纳。如果没有,请问。这将帮助其他有同样问题的程序员以及那些也想提供帮助的程序员。所以他们知道有答案
标签: python selenium bots whatsapp