from urllib.request import urlopen from bs4 import BeautifulSoup html = urlopen("http://www.pythonscraping.com/pages/warandpeace.html") bs = BeautifulSoup(html) n = bs.findAll(text="the prince") for nx in n: print(nx)