gpt4 book ai didi

python - 将扩展与 Google Chrome Selenium 驱动程序一起使用

转载 作者:行者123 更新时间:2023-11-28 22:50:59 29 4
gpt4 key购买 nike

我正在尝试像这样添加我的扩展:

from selenium.webdriver.chrome.options import Options
import os
executable_path = "C:/Chrome/chromedriver.exe"
os.environ["webdriver.chrome.driver"] = executable_path
chrome_options = Options()
chrome_options.add_extension('C:/Users/Wilson/AppData/Local/Google/Chrome/User Data/Default/Extensions')

driver = webdriver.Chrome(executable_path=executable_path, chrome_options=chrome_options)

但出现以下错误:

Traceback (most recent call last):
File "C:/Users/Wilson/Dropbox/xxx.py", line 77, in <module>
driver = webdriver.Chrome(executable_path=executable_path, chrome_options=chrome_options)
File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 55, in __init__
desired_capabilities = options.to_capabilities()
File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\options.py", line 140, in to_capabilities
chrome_options["extensions"] = self.extensions
File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\options.py", line 76, in extensions
file_ = open(ext, 'rb')
PermissionError: [Errno 13] Permission denied: 'C:/Users/Wilson/AppData/Local/Google/Chrome/User Data/Default/Extensions'

不太确定我做错了什么。任何帮助将不胜感激。

最佳答案

    chop = webdriver.ChromeOptions()
chop.add_argument('load-extension=path/to/extension')

用你想要的扩展试试这个,看看它是否仍然给你同样的错误

这是python的语法

关于python - 将扩展与 Google Chrome Selenium 驱动程序一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22130671/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com