Python 如何在普通浏览器中使用selenium
是否可以将selenium连接到我通常使用的浏览器,而不是驱动程序?对于正常的浏览,我使用chrome和几个插件——添加block plus、flashblock和更多插件。我想尝试使用此特定配置加载站点。我该怎么做 p、 s-我不想只连接到打开的浏览器,如以下问题: 我不在乎是否使用驱动程序生成进程。我只需要完整的浏览器配置-cookies,插件,字体等Python 如何在普通浏览器中使用selenium,python,python-2.7,selenium,Python,Python 2.7,Selenium,是否可以将selenium连接到我通常使用的浏览器,而不是驱动程序?对于正常的浏览,我使用chrome和几个插件——添加block plus、flashblock和更多插件。我想尝试使用此特定配置加载站点。我该怎么做 p、 s-我不想只连接到打开的浏览器,如以下问题: 我不在乎是否使用驱动程序生成进程。我只需要完整的浏览器配置-cookies,插件,字体等 谢谢首先,您需要下载,然后将可执行路径放入环境变量path中,或者在executable\u path参数中传递路径: from sele
谢谢首先,您需要下载,然后将可执行路径放入环境变量
path
中,或者在executable\u path
参数中传递路径:
from selenium import webdriver
driver = webdriver.Chrome(executable_path='/path/to/executeable/chrome/driver')
为了加载扩展,您需要设置ChromeOptions
:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_extension('Adblock-Plus_v1.4.1.crx')
driver = webdriver.Chrome(chrome_options=options)
您还可以保存您拥有的chrome用户配置文件并将其加载到ChromeDriver
:
options = webdriver.ChromeOptions()
options.add_argument('--user-data-dir=/path/to/my/profile')
driver = webdriver.Chrome(chrome_options=options)
另见: