And*_*eas 2 python-3.x selenium-chromedriver selenium-webdriver
也许有人可以帮助使用 Windows、Python、Selenium 以及使用 Chrome Webdriver 和 ChromePortable。
我定义了一个新文件夹
c:\我的项目
wedriver 在此文件夹中位于:c:\myproject\driver\chromedriver.exe
还有 Chrome 便携式
c:\myproject\chromeportable\chrome.exe
现在我想构建一个简单的 Python 脚本,该脚本可以打开 - 比方说 - stackoverflow.com。
在安装了谷歌的计算机上,这不是一个问题
from selenium import webdriver
driver = webdriver.Chrome("c:\myproject\driver\chromedriver.exe")
driver.get("https://stackoverflow.com")
Run Code Online (Sandbox Code Playgroud)
但是,如果没有安装谷歌浏览器并且应该使用谷歌浏览器便携式,如何更改脚本?
任何想法?提前非常感谢您,祝您度过美好的一天安德烈亚斯
小智 5
使用选项类:
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "c:\myproject\chromeportable\chrome.exe"
# you may need some other options
#options.add_argument('--no-sandbox')
#options.add_argument('--no-default-browser-check')
#options.add_argument('--no-first-run')
#options.add_argument('--disable-gpu')
#options.add_argument('--disable-extensions')
#options.add_argument('--disable-default-apps')
driver = webdriver.Chrome("c:\myproject\driver\chromedriver.exe",
options=options)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10439 次 |
| 最近记录: |