diff options
Diffstat (limited to 'examples/htmlStripper.py')
-rw-r--r-- | examples/htmlStripper.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/htmlStripper.py b/examples/htmlStripper.py index 18f3395..eb35c70 100644 --- a/examples/htmlStripper.py +++ b/examples/htmlStripper.py @@ -6,8 +6,8 @@ # # Copyright (c) 2006, 2016, Paul McGuire # -from contextlib import closing -import urllib.request, urllib.parse, urllib.error +import urllib.parse, urllib.error +from urllib.request import urlopen from pyparsing import (makeHTMLTags, commonHTMLEntity, replaceHTMLEntity, htmlComment, anyOpenTag, anyCloseTag, LineEnd, OneOrMore, replaceWith) @@ -17,7 +17,7 @@ commonHTMLEntity.setParseAction(replaceHTMLEntity) # get some HTML targetURL = "https://wiki.python.org/moin/PythonDecoratorLibrary" -with closing(urllib.request.urlopen( targetURL )) as targetPage: +with urlopen( targetURL ) as targetPage: targetHTML = targetPage.read().decode("UTF-8") # first pass, strip out tags and translate entities |