<p>这个答案很简单,而且可以自我解释。</p>
<pre class="lang-py prettyprint-override"><code>from selenium import webdriver
from selenium.webdriver.chrome.options import Options
exec_path_chrome = "path/to/Google Chrome" #Do not use this path that is extracted from "chrome://version/"
exec_path_driver = "path/to/chromedriver"
ch_options = Options() #Chrome Options
ch_options.add_argument("user-data-dir = /path/to/Chrome Profile") #Extract this path from "chrome://version/"
driver = webdriver.Chrome(executable_path = exec_path_driver, options = ch_options) #Chrome_Options is deprecated. So we use options instead.
driver.get("https://stackoverflow.com/a/57894065/4061346")
</code></pre>
<p>正如@MadRabbit所说,在地址栏中键入<code>chrome://version/</code>,以查找chrome配置文件数据的路径。</p>
<ul>
<li>在Windows中似乎是这样的<code>C:\Users\pc\AppData\Local\Google\Chrome\User Data\Default</code></li>
<li>在Mac <code>/Users/user/Library/Application Support/Google/Chrome/Default</code>中似乎是这样的</li>
</ul>
<p>因此,您所要做的就是从概要文件路径中删除最后一部分<strike><code>Default</code></strike>。</p>
<blockquote>
<p><strong>Note:</strong> Make sure you don't run more than one session at the same time to avoid problems.</p>
</blockquote>