get div from HTML with Python

html, python, regex

Solution

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!

Problem

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

Original source