Here's exactly what you need.
The idea is to define a list of keys/labels you are interested in, find all b
elements and check if the text in the b
element is in the list of key/labels. If yes - print out the text of b
element and the next sibling:
from bs4 import BeautifulSoup
data = """<span id= "here" style>
<br>
<b> Post Primary</b>
<b>school<b>
<br>
<b>Roll number: </b>b>
"60000"
<br>
<b>Principal</b>
"Paul Ince"
<br>
<b>Enrolment:</b>
"Boys; 123 Girls: 102 (2012/13)"
<br>
<b>Ethos:</b>
"Catholic   "
<b>Catchment:</b>
"North Inner CIty "
<br>
<b>Fees:</b>
" No "
</span>"""
soup = BeautifulSoup(data)
keys = ['Enrolment', 'Ethos', 'Fees']
for element in soup('b'):
if element.text[:-1] in keys:
print element.text + element.next_sibling.strip()
prints:
Enrolment:"Boys; 123 Girls: 102 (2012/13)"
Ethos:"Catholic   "
Fees:" No "
Hope that helps.