Created
June 16, 2012 02:01
-
-
Save mshmsh5000/2939602 to your computer and use it in GitHub Desktop.
Sitemap-driven crawler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.dom.minidom, urllib | |
def getText(nodelist): | |
rc = [] | |
for node in nodelist: | |
if node.nodeType == node.TEXT_NODE: | |
rc.append(node.data) | |
return ''.join(rc) | |
dom = xml.dom.minidom.parseString(urllib.urlopen('http://www.lesters.com/sitemap/sitemap.xml').read()) | |
locs = dom.getElementsByTagName('loc') | |
for loc in locs: | |
url = getText(loc.childNodes) | |
urllib.urlretrieve(url) | |
print url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment