1#!/usr/bin/python
2
3from bs4 import BeautifulSoup
4
5with open('index.html', 'r') as f:
6
7 contents = f.read()
8
9 soup = BeautifulSoup(contents, 'lxml')
10
11 tags = soup.find_all(['h2', 'p'])
12
13 for tag in tags:
14 print(' '.join(tag.text.split()))
15