Windows 安装 chromedriver 和 Python 调试

下载 chromedriver

从官方网站上下载 chromedriver 的版本,这个版本需要和你 Chrome 的版本对应上。

下载的地址为:ChromeDriver - WebDriver for Chrome - Downloads

这个地方,将会打开一个新的浏览器界面,Chrome for Testing availability

在这个新的浏览器界面中,我们能看到对应的 Chrome 版本号。

查看 Chrome 版本

通过查看 Chrome 的版本来查看关于的信息。

通过这个 Chrome 的版本来下载 chromedriver 的版本。

解压到特定目录

解压到特定的目录后就可以使用了。

Python 代码

如果需要在 python 中直接进行使用。

需要导入的包:

from selenium.webdriver import Chrome
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

使用代码来进行运行浏览器

chrome = Chrome(service=Service(r"C:\Users\yhu\Downloads\chromedriver-win64\chromedriver-win64\chromedriver.exe"))
chrome.get('https://www.isharkfly.com/')

通过上面的代码就可以在 chromedriver 上打开浏览器后查看下载的原始内容。

如果你有 IDE 的断点调试功能的话,这个使用应该可以查看断点中的内容。

上图是运行代码后,通过断点查看对象中访问网站的内容。