Fetch all href link using selenium in python

前端 未结 6 2059
孤街浪徒
孤街浪徒 2020-12-04 14:41

I am practicing Selenium in Python and I wanted to fetch all the links on a web page using Selenium.

For example, I want all the links in the href= prop

6条回答
  •  孤街浪徒
    2020-12-04 15:30

    I have checked and tested that there is a function named find_elements_by_tag_name() you can use. This example works fine for me.

    elems = driver.find_elements_by_tag_name('a')
        for elem in elems:
            href = elem.get_attribute('href')
            if href is not None:
                print(href)
    

提交回复
热议问题