How to find elements by class

后端 未结 17 1648
有刺的猬
有刺的猬 2020-11-22 08:33

I\'m having trouble parsing HTML elements with \"class\" attribute using Beautifulsoup. The code looks like this

soup = BeautifulSoup(sdata)
mydivs = soup.fi         


        
17条回答
  •  不要未来只要你来
    2020-11-22 09:14

    Concerning @Wernight's comment on the top answer about partial matching...

    You can partially match:

    • and

    with gazpacho:

    from gazpacho import Soup
    
    my_divs = soup.find("div", {"class": "stylelistrow"}, partial=True)
    

    Both will be captured and returned as a list of Soup objects.

提交回复
热议问题