from mechanize import Browser
br = Browser()
br.open(\'http://somewebpage\')
html = br.response().readlines()
for line in html:
print line
When p
You can use BeautifulSoup get_text() feature.
from bs4 import BeautifulSoup
html_str = '''
Please can you strip me?
I am waiting....
'''
soup = BeautifulSoup(html_str)
print(soup.get_text())
#or via attribute of Soup Object: print(soup.text)
It is advisable to explicitly specify the parser, for example as BeautifulSoup(html_str, features="html.parser")
, for the output to be reproducible.