安装Selenium快速指南(Google Chrome版本)

To set up Selenium, you must first have Python installed. I recommend installing Python 3 via Anaconda, which is detailed here. This will also give you the Spyder development environment, which I recommend as well.

要设置Selenium,您必须首先安装Python。 我建议通过Python,它详细介绍安装Python 3 这里 。 这也将为您提供我推荐的Spyder开发环境。

Next, if you’re using Windows, open up your command prompt and type:

接下来,如果您使用的是Windows,请打开命令提示符并键入:

pip install selenium

or an equivalent command in Mac or Linux Terminal.

或Mac或Linux Terminal中的等效命令。

Now that Selenium is installed, you need to pick a web browser for Selenium to use. To get things up and running with the fewest possible errors, I recommend starting with Google Chrome. Firefox is my personal preference, but as things now stand there can be a few kinks with setting it up, so we’ll focus on Chrome for now. Assuming Chrome is installed, go to the following website:

现在已经安装了Selenium,您需要选择一个Web浏览器供Selenium使用。 为了使一切正常运行,并尽可能减少错误,建议您从Google Chrome浏览器开始。 Firefox是我的个人喜好,但从目前的情况来看,可能需要进行一些设置,因此我们现在将重点介绍Chrome。 假设已安装Chrome,请访问以下网站:

https://sites.google.com/a/chromium.org/chromedriver/downloads

https://sites.google.com/a/chromium.org/chromedriver/downloads

Follow the link to the latest release and download the appropriate driver for your machine. Unzip the driver and move it to whatever place in your file system you prefer. Just keep in mind you will need to reference the Chrome driver’s location when you use Selenium.

单击链接到最新版本,并下载适用于您的计算机的驱动程序。 解压缩驱动程序并将其移动到文件系统中您喜欢的任何位置。 请记住,使用Selenium时需要参考Chrome驱动程序的位置。

Finally, to make sure everything is working as it should, run this code:

最后,要确保一切正常,请运行以下代码:

from selenium import webdriver

## your executable path is wherever you saved the Chrome webdriver
browser = webdriver.Chrome(executable_path="C:UsersgstantonDownloadschromedriver.exe")
url = "https://www.google.com"
browser.get(url)

翻译自: https://www.pybloggers.com/2016/10/quick-guide-to-installing-selenium-google-chrome-version/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值