summaryrefslogtreecommitdiff
path: root/examples/urlExtractorNew.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/urlExtractorNew.py')
-rw-r--r--examples/urlExtractorNew.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/urlExtractorNew.py b/examples/urlExtractorNew.py
index d876eea..795322a 100644
--- a/examples/urlExtractorNew.py
+++ b/examples/urlExtractorNew.py
@@ -1,8 +1,8 @@
# URL extractor
# Copyright 2004, Paul McGuire
from pyparsing import makeHTMLTags
-from contextlib import closing
-import urllib.request, urllib.parse, urllib.error
+import urllib.parse, urllib.error
+from urllib.request import urlopen
import pprint
# Define the pyparsing grammar for a URL, that is:
@@ -15,7 +15,7 @@ linkOpenTag, linkCloseTag = makeHTMLTags("a")
link = linkOpenTag + linkOpenTag.tag_body("body") + linkCloseTag.suppress()
# Go get some HTML with some links in it.
-with closing(urllib.request.urlopen("https://www.cnn.com/")) as serverListPage:
+with urlopen("https://www.cnn.com/") as serverListPage:
htmlText = serverListPage.read()
# scanString is a generator that loops through the input htmlText, and for each