import refrom bs4 import BeautifulSouphtml_doc = """The Dormouse's story The Dormouse's story
Once upon a time there were three little sisters; and their names wereElsie,Lacie andTillie;and they lived at the bottom of a well.
...
"""soup = BeautifulSoup(html_doc, 'html.parser')links = soup.find('a',href=re.compile(r'ill'))print links.get_text()links = soup.find('p',class_="title")print links.get_text(),links.name