Wednesday, July 3, 2024
HomeLanguagesPythonPrint All Link Name Using Selenium In Python

Print All Link Name Using Selenium In Python

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.

Requirements:

You need to install chromedriver and set path. Click here to download.

Note: For more information follows this link.

Step-by-step Approach:

  • Import required modules
  • Taking any URL.
  • using By.TAG_NAME find web link on a webpage.
  • then use a loop for print link name.

Implementation:

Python3




#import module
from selenium import webdriver
from selenium.webdriver.common.by import By
  
  
driver = webdriver.Chrome()
  
# url
  
# find web links
link = driver.find_elements(By.TAG_NAME, 'a')
  
# print name of all links
for i in link:
    print(i.text)


Output:

Calisto Chipfumbu
Calisto Chipfumbuhttp://cchipfumbu@gmail.com
I have 5 years' worth of experience in the IT industry, primarily focused on Linux and Database administration. In those years, apart from learning significant technical knowledge, I also became comfortable working in a professional team and adapting to my environment, as I switched through 3 roles in that time.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments