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 Microsoft Edge through Python.
Start by determining what version of Edge you have on your computer
Click the three horizontal lines in the upper right corner > Help and Feedback>About Microsoft Edge
Search for msedgedriver to download the file that matches your Edge version. (note, this is something you will need to do every time Edge is updated, so get used to it.)
Open up the zipfile you downloaded, you will find a file called msedgedriver.exe
Put it somewhere you can find, put in the following code to let Python know where to find it.
from selenium import webdriver opts = webdriver.Edge() dr = webdriver.Edge('C:/Users/larsobe/Desktop/msedgedriver.exe',chrome_options=opts)
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.