I have this HTML from which I have to extract data:
<html>
<head></head>
<body>
<div class="main">
<div class="utlimate"><p>hello</p></div>
<div class = "headline"><p>some text</p></div>
<div class="content">
<div class = "utimate"> <p>TOP</p>
<div class ="utlimate"> <p>data1</p></div>
<div class ="utlimate"> <p>it could be anything</p></div>
<div class ="utlimate"> <p>not</p></div>
<div class ="utlimate"> <p></p></div>
</div>
</div>
</div>
</body>
</html>
I need to access <div class="ultimate"> with <p> that has value “data1”, “it could be anything”, “not”.The code I tried for this :
soup = BeautifulSoup(HTML_data) #HTML_data is all html content
first_div = soup.find('div',{"class" : "content"})
second_div = first_div.find('div',{"class" : "utlimate"})
div_list = second_div.findall('div',{"class" : "utlimate"})
I got error in my code last line ‘NoneType’ object is not callable
How do i access only those div’s???plz help
Try this:
The method for getting the list is
findAll, notfindall.There’s no “ultimate” in the HTML fragment, they’re “utlimate” or “utimate”. Are those typos?