Last active
August 29, 2015 14:20
-
-
Save tomkralidis/be69d2e24ac64619e726 to your computer and use it in GitHub Desktop.
Download CSW metadata
This file contains hidden or 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 sys | |
| from owslib.csw import CatalogueServiceWeb | |
| if len(sys.argv) < 3: | |
| print 'Usage: %s <csw-endpoint> <max-records>' | |
| sys.exit(1) | |
| URL = sys.argv[1] | |
| MAXRECORDS = sys.argv[2] or 10 | |
| CSW = CatalogueServiceWeb(URL) | |
| CSW.getrecords2(maxrecords=MAXRECORDS, outputschema='http://www.isotc211.org/2005/gmd', esn='full') | |
| for key, value in CSW.records.iteritems(): | |
| filename = 'xml/%s.xml' % key | |
| with open(filename, 'w') as ff: | |
| ff.write(value.xml) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment