Fetch all href link using selenium in python

前端 未结 6 2054
孤街浪徒
孤街浪徒 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:22

    import requests
    from selenium import webdriver
    import bs4
    driver = webdriver.Chrome(r'C:\chromedrivers\chromedriver') #enter the path
    data=requests.request('get','https://google.co.in/') #any website
    s=bs4.BeautifulSoup(data.text,'html.parser')
    for link in s.findAll('a'):
        print(link)
    

提交回复
热议问题