Date: Tue, 19 Mar 2024 09:54:45 +0100 (CET) Message-ID: <1497823340.76.1710838485217@v-public003.directory.intra> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_75_1351095247.1710838485217" ------=_Part_75_1351095247.1710838485217 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This is example code to explore and later on retrieve metadata f= rom a catalogue service for the web (CSW) using Python.
#load d= ependencies import sys from owslib.csw import CatalogueServiceWeb # support function def showhelp(): astring =3D """ description: - First attempt to retrieve the metadata in a CSW. =20 versions: - v0.1 gives a list of datasets available =20 usage: - python getCSWdata.py urltoCSW =20 for instance the PMR CSW url =3D 'http://pmr-geoserver.deltares.nl/geonetwork/srv/eng/csw?' """ print astring # give listing of available datasets def displayrecords(url): try: csw =3D CatalogueServiceWeb(url,skip_caps=3DTrue) csw.getrecords2() csw.results for rec in csw.records: print csw.records[rec].title except: print 'something went wrong' def nextstep(url): msg =3D """ Right now you get a listing of the available datasets in the {u} commit= ted.=20 Next step would be te rectrieve the complete metadata. This is not impl= emented yet.""".format(u=3Durl) print msg return if __name__ =3D=3D '__main__': if len(sys.argv) <=3D 1: showhelp() sys.exit() if sys.argv[1] =3D=3D'?': showhelp() =20 sys.exit() url =3D sys.argv[1] nextstep(url) displayrecords(url)