from BeautifulSoup import BeautifulSoup
doc = ['<html><head><title>Page title</title></head>',
    '<body><p id="firstpara" align="center">This is paragraph <b>one</b>.',
    '<p id="secondpara" align="blah">This is paragraph <b>two</b>.', '</html>']
soup = BeautifulSoup(''.join(doc))
print(soup.prettify())
Python BeautifulSoup извлекает текст между элементами