summaryrefslogtreecommitdiff
path: root/src/examples/scanYahoo.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/scanYahoo.py')
-rw-r--r--src/examples/scanYahoo.py14
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