How To Install Chromedriver In Selenium Webdriver
Installing Selenium and Chromedriver on Windows
If you want to use Selenium to scrape web sites with Chrome, just follow these steps!
This article assumes the reader knows the following:
- How to open a Python interpreter in a command prompt or how to run a Python script
- What 'web scraping' is
- Why a person would want to apply Selenium and chromediver to accomplish their scraping chore
Pace 1: Download and install Google Chrome
You lot probably already have Chrome installed, simply if you don't, yous can get it here.
Stride two: Download Chromedriver and shop information technology somewhere
Chromedriver is produced by the team behind Chrome and allows Chrome to be automatically controlled past Selenium. This is the trickiest step.
- Get to the latest release of chromedriver by going to the official download page.
- Click through until you run across a page that looks like this and click on your version to download it.
iii. Unzip the downloaded file
four. Movement the chromedriver.exe file to a permanent home. Information technology's easiest to place it in c:\windows because that directory is already a part of the system path. If you lot choose to store it somewhere else (e.yard. c:\selenium like I do), you'll need to add that directory to your path. Here'due south some instructions on how to do that.
Pace iii: Install selenium using pip
- Open your Windows Command Prompt (or cmder if you lot're cool)
- If you're using Conda or Virtualenv, fire upwardly the surroundings you want to use (if you lot don't know what this is, just skip it for now and practise some googling later!)
- Run the following
pip install selenium Step 4: Test it out!
Here's some Python code that y'all can run to make sure that your setup is working. It should popular up a Chrome window, take you to the NASA website, and then print out the headlines from that site.
from selenium import webdriver
driver = webdriver.Chrome()
driver.become('https://www.nasa.gov')
headlines = commuter.find_elements_by_class_name("headline")
for headline in headlines:
print(headline.text.strip())
driver.close() Troubleshooting
If you run into any issues, it'southward likely because you didn't put the chromedriver.exe file in a folder that has been added to your system path, so try to correct that commencement before doing whatever other troubleshooting.
Source: https://medium.com/@patrick.yoho11/installing-selenium-and-chromedriver-on-windows-e02202ac2b08
Posted by: rinkphan1991.blogspot.com

0 Response to "How To Install Chromedriver In Selenium Webdriver"
Post a Comment