from mechanize import Browser
br = Browser()
br.open(\'http://somewebpage\')
html = br.response().readlines()
for line in html:
print line
When p
I haven't thought much about the cases it will miss, but you can do a simple regex:
re.sub('<[^<]+?>', '', text)
For those that don't understand regex, this searches for a string Hello<...>
, where the inner content is made of one or more (+
) characters that isn't a <
. The ?
means that it will match the smallest string it can find. For example given
, it will match <'p>
and
?
. Without it, it will match the entire string <..Hello..>
.
If non-tag <
appears in html (eg. 2 < 3
), it should be written as an escape sequence &...
anyway so the ^<
may be unnecessary.