Selenium is a Python package that allows you to control web browsers through Python. In this tutorial (and the following tutorials), we will be connecting to Googles Chrome browser, Selenium does work with other browsers as well.
First you will need to download Selenium, you can use the following commands depending on your Python distribution
c:\> Pip install selenium
c:\> Conda install selenium
If you are on a work computer or dealing with a restrictive VPN, the offline install option may help you: Selenium_Install_Offline
Next you need to download the driver that let’s you manage Chrome through Python.
Start by determining what version of Chrome you have on your computer
Go to https://chromedriver.chromium.org/downloads to download the file that matches your Chrome version. (note, this is something you will need to do every time Chrome is updated, so get used to it.)
Open up the zipfile you downloaded, you will find a file called chromedriver.exe
Put it somewhere you can find, put in the following code to let Python know where to find it.
from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument("--start-maximized") dr = webdriver.Chrome('C:/Users/larsobe/Desktop/chromedriver.exe',chrome_options=options)
Now to see if this works, use the following line, (you can try another website if you choose)
You are now running a web browser via Python.