How to find elements by class

后端 未结 17 1451
有刺的猬
有刺的猬 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 08:57

    This should work:

    soup = BeautifulSoup(sdata)
    mydivs = soup.findAll('div')
    for div in mydivs: 
        if (div.find(class_ == "stylelistrow"):
            print div
    

提交回复
热议问题