1# to get the title from BeautifulSoup
2soup = ('html_file', 'html.parser')
3print(soup.title)
1# to get the title from BeautifulSoup
2soup = ('html_file', 'html.parser')
3print(soup.title.string)
1for body in message.find_all('div', {'class': 'body'}):
2 # grab div by class name
3 if body.find('div', {'class': 'date'}):
4 text = body.find('div', {'class': 'date'})
5 # find div by 'title' attribute
6 title = text.get('title', 'No title attribute')
7 print(title)