pattern = re.compile("test") element = soup_object.find('a', text=pattern).parent
http://stackoverflow.com/questions/866000/using-beautifulsoup-to-find-a-html-tag-that-contains-certain-text