How to perform web automation using Python? | Web Scraping using Selenium.
For performing web automation or web scraping using
python:
- Install Selenium using pip command.
- Download browser driver.
- Write Python code using any IDE.
How to install Selenium using pip command?
Open command prompt and type pip install selenium
and wait for a while to get it installed.
If you are using mac or linux, write pip3 instead of pip.
How to Download browser driver?
Download browser driver from the internet. Here in my case, I am using driver for Google Chrome. However, you can use other browser also.I am suing Google Chrome 86 version, so i am selecting second option.
Extract the driver and place it in the c->proramme File folder for easy access. However, you can place it anywhere in your computer. Copy this path.
Write the following python code in an IDE. I am using Visual Editor.
from selenium import webdriver
PATH="C:\Program Files\chromedriver.exe"
driver=webdriver.Chrome(PATH)
driver.get("https:www.phdtalks.org")
driver.close() # for quitting the current tab of a browser.
driver.quit() # for quiting the Browser.
print(driver.title) # for printing the title of a web page.
Comments
Post a comment