diff options
Diffstat (limited to 'examples/urlExtractor.py')
-rw-r--r-- | examples/urlExtractor.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/examples/urlExtractor.py b/examples/urlExtractor.py index 70835da..2d29200 100644 --- a/examples/urlExtractor.py +++ b/examples/urlExtractor.py @@ -4,11 +4,11 @@ from pyparsing import makeHTMLTags, pyparsing_common as ppc from urllib.request import urlopen import pprint -linkOpenTag, linkCloseTag = makeHTMLTags('a') +linkOpenTag, linkCloseTag = makeHTMLTags("a") linkBody = linkOpenTag.tag_body linkBody.setParseAction(ppc.stripHTMLTags) -linkBody.addParseAction(lambda toks: ' '.join(toks[0].strip().split())) +linkBody.addParseAction(lambda toks: " ".join(toks[0].strip().split())) link = linkOpenTag + linkBody("body") + linkCloseTag.suppress() @@ -24,6 +24,4 @@ for toks, strt, end in link.scanString(htmlText): # Create dictionary from list comprehension, assembled from each pair of tokens returned # from a matched URL. -pprint.pprint( - {toks.body: toks.href for toks, strt, end in link.scanString(htmlText)} - ) +pprint.pprint({toks.body: toks.href for toks, strt, end in link.scanString(htmlText)}) |