Skip to content
Related Articles

Related Articles

Improve Article

Count total number of Links In Webpage Using Selenium In Python

  • Last Updated : 04 Jan, 2021

Selenium is a powerful tool for controlling web browsers through programs and performing browser automation. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python.


1.1 Selenium Bindings in Python
Selenium Python bindings provide a convenient API to access Selenium Web Driver like Firefox,Chrome,etc.

Pip install Selenium 

1.2 Web Drivers
Selenium requires a web driver to interface with the chosen browser. Web drivers is a package to interact with a web browser. It interacts with the web browser or a remote web server through a wire protocol which is common to all. You can check out and install the web drivers of your browser choice.


Step-by-step Approach:

  • Import required modules


# import modules 
from selenium import webdriver 
from import By 
import time


# assign web page url 
  • using By.TAG_NAME find web link in webpage.



#import module
from selenium import webdriver
from import By
driver = webdriver.Chrome()
# url
# find web links
link = driver.find_elements(By.TAG_NAME, 'a')
# using len function count how many links


 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :