get div from HTML with Python
21,249
I would use BeautifulSoup
!
to get everything with <div>
tag just do:
soup = BeautifulSoup(html)#make soup that is parse-able by bs
soup.findAll('div')
to get the value inside of span you could do:
soup.find('span').get_text()
there are tons of differnt methods of getting the informaton you need
Good Luck hope this helps!
Author by
JoseMiguel
Updated on January 08, 2020Comments
-
JoseMiguel over 4 years
I want to get a value inside certain div from a HTML page
<div class="well credit"> <div class="span2"> <h3><span> $ 5.402 </span></h3> </div> </div>
I've done it with regular expressions ( re.seach() ) but it take too long to find the div since it's a huge html.
Is there a way to do this faster but with no external libraries?
Thanks