how to extract all the data between &nbsp;
Question: 
    <p align="JUSTIFY"><a href="#abcd"> Mr A </a></p>
    <p align="JUSTIFY">I </p>
    <p align="JUSTIFY"> have a question </p>
    <p align="JUSTIFY">&nbsp;</p>
    <p align="JUSTIFY"><a href="#mnop"> Mr B </a></p>
    <p align="JUSTIFY">The </p>
    <p align="JUSTIFY">answer is</p>
    <p align="JUSTIFY">not there</p>
    <p align="JUSTIFY">&nbsp;</p>
    <p align="JUSTIFY"><a href="wxyz"> Mr C </a></p>
    <p align="JUSTIFY">Please</p>
    <p align="JUSTIFY">Help</p>
    

I want to iterate the extraction of the data with the help of `&nbsp;`.

  * The first iteration should display _I have a question_
  * second iteration should display _The answer is not there_
  * The person names should also be extracted in a different list ..for example ['Mr A','Mr B','Mr C']

If someone has any idea how to do it, it might be useful because I am trying
to learn python got stuck with this problem.The code i tried is

    
    
    for t in soup.findAll('p',text = re.compile('&nbsp;'), attrs = {'align' : 'JUSTIFY'}):
        print t
        for item in t.parent.next_siblings:
            if isinstance(item, Tag):
                if 'p' in item.attrs and 'align' in item.attrs['p']:
                    break
                print item
    

It return [] which is not what want


Answer: You can do that with BeautifulSoup:

    
    
    from bs4 import BeautifulSoup
    
    s = ""
    
    html = '<p align="JUSTIFY">I </p>\
    <p align="JUSTIFY"> have a question </p>\
    <p align="JUSTIFY">&nbsp;</p>\
    <p align="JUSTIFY">The </p>\
    <p align="JUSTIFY">answer is</p>\
    <p align="JUSTIFY">not there</p>\
    <p align="JUSTIFY">&nbsp;</p>\
    <p align="JUSTIFY">Please</p>\
    <p align="JUSTIFY">Help</p>'
    
    soup = BeautifulSoup(html)
    title = soup.findAll("p", {"align" : "JUSTIFY"})
    
    for i in title:
        s += ''.join(i.contents)
    
    f =  s.split("&nbsp;")
    for i in f:
        print i
    

