How to find elements by class

后端 未结 17 1443
有刺的猬
有刺的猬 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:53

    A straight forward way would be :

    soup = BeautifulSoup(sdata)
    for each_div in soup.findAll('div',{'class':'stylelist'}):
        print each_div
    

    Make sure you take of the casing of findAll, its not findall

提交回复
热议问题