diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2012-10-02 04:55:56 +0000 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2012-10-02 04:55:56 +0000 |
commit | a7f9dda0668bfce4fba51df1bf2976b4a93a8bd5 (patch) | |
tree | 57ea8bcf2e66532a36c833a7bc57cff9d5d0e4dd /src/examples/scanYahoo.py | |
parent | f5d2b716ffb57b65660a7ee0bbf04332dfb29620 (diff) | |
download | pyparsing-git-a7f9dda0668bfce4fba51df1bf2976b4a93a8bd5.tar.gz |
Add example files to SVN
Diffstat (limited to 'src/examples/scanYahoo.py')
-rw-r--r-- | src/examples/scanYahoo.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/examples/scanYahoo.py b/src/examples/scanYahoo.py new file mode 100644 index 0000000..0596fad --- /dev/null +++ b/src/examples/scanYahoo.py @@ -0,0 +1,14 @@ +from pyparsing import makeHTMLTags,SkipTo,htmlComment
+import urllib
+
+serverListPage = urllib.urlopen( "http://www.yahoo.com" )
+htmlText = serverListPage.read()
+serverListPage.close()
+
+aStart,aEnd = makeHTMLTags("A")
+
+link = aStart + SkipTo(aEnd).setResultsName("link") + aEnd
+link.ignore(htmlComment)
+
+for toks,start,end in link.scanString(htmlText):
+ print toks.link, "->", toks.startA.href
\ No newline at end of file |