selenium 打开谷歌本地浏览器

192 阅读1分钟
  1. 找到谷歌的可执行文件,然后执行.\chrome.exe --remote-debugging-port=9225 --user-data-dir="E:\chrome\data"

from selenium import webdriver from selenium.webdriver.chrome.options import Options

web_url = "www.17track.net/zh-cn"

加载cookies中已经保存的账号和密码

options = Options() options.add_experimental_option("debuggerAddress", "127.0.0.1:9225") browser = webdriver.Chrome(options=options, executable_path=r"E:\chrome\chromedriver-win64\chromedriver.exe") browser.get(web_url)

3.执行有可能报错 # ValueError: Timeout value connect was <...>, but it must be an int, float or None.
4.解决方法 pip install urllib3==1.26.2