import re
from bs4 import BeautifulSoup
html_doc = """
<html>
<body>
<span class="blue">here is a lot of text that i don't need</span>
<span class="blue">this is the span i need because it contains 04/18/13 7:29pm</span>
<span class="blue">04/19/13 7:30pm</span>
<span class="blue">Posted on 04/20/13 10:31pm</span>
</body>
</html>
"""
soup = BeautifulSoup(html_doc)
spans = soup.find_all('span', {'class': 'blue'})
lines = [span.get_text() for span in spans]
found_dates = []
for line in lines:
    m = re.search('(\\d{2}/\\d{2}/\\d{2} \\d+:\\d+[a|p]m)', line)
if m:
    found_dates.append(m.group(1))
for date in found_dates:
    pass
How to find spans with a specific class containing specific text using beautiful soup and re?