summaryrefslogtreecommitdiff
path: root/examples/scanYahoo.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/scanYahoo.py')
-rw-r--r--examples/scanYahoo.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/scanYahoo.py b/examples/scanYahoo.py
new file mode 100644
index 0000000..825c169
--- /dev/null
+++ b/examples/scanYahoo.py
@@ -0,0 +1,14 @@
+from pyparsing import makeHTMLTags,SkipTo,htmlComment
+import urllib.request, urllib.parse, urllib.error
+
+serverListPage = urllib.request.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