Fetch all href link using selenium in python

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

    Unfortunately, the original link posted by OP is dead...

    If you're looking for a way to scrape links on a page, here's how you can scrape all of the "Hot Network Questions" links on this page with gazpacho:

    from gazpacho import Soup
    
    url = "https://stackoverflow.com/q/34759787/3731467"
    
    soup = Soup.get(url)
    a_tags = soup.find("div", {"id": "hot-network-questions"}).find("a")
    
    [a.attrs["href"] for a in a_tags]
    

提交回复
热议问题