Fetch all href link using selenium in python

Well, you have to simply loop through the list:

elems = driver.find_elements_by_xpath("//a[@href]")
for elem in elems:
    print(elem.get_attribute("href"))

find_elements_by_* returns a list of elements (note the spelling of ‘elements’). Loop through the list, take each element and fetch the required attribute value you want from it (in this case href).

Leave a Comment