<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Thanks  James!</p>
<p><br>
</p>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family: Calibri, sans-serif;">from owslib.csw import CatalogueServiceWeb</span></p>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family: Calibri, sans-serif;">from owslib.fes import PropertyIsEqualTo, PropertyIsLike, BBox</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family: Calibri, sans-serif;"><br>
</span></p>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family: Calibri, sans-serif;">csw = CatalogueServiceWeb('https://catalog.data.gov/csw')</span></p>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family: Calibri, sans-serif;">query = PropertyIsEqualTo('csw:AnyText', 'Africa')</span></p>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family: Calibri, sans-serif;">csw.getrecords2(constraints=[query], maxrecords=20)</span></p>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family: Calibri, sans-serif;">print(csw.records)</span></p>
</div>
<div><br>
</div>
it works like a charm.
<div><br>
<div>Davide<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Da:</b> Passmore, James H. <jpass@bgs.ac.uk><br>
<b>Inviato:</b> venerdì 2 giugno 2017 10.48<br>
<b>A:</b> Davide Muraro; owslib-users@lists.osgeo.org<br>
<b>Oggetto:</b> RE: CatalogueServiceWeb and data.gov exception</font>
<div> </div>
</div>
<div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D">The line</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">csw = CatalogueServiceWeb('http://catalog.data.gov/csw?service=CSW&version=2.0.2&request=GetCapabilities')</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D">should be:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">csw = CatalogueServiceWeb('http://catalog.data.gov/csw')
</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">or (as you’re getting redirected to an https service):</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">csw = CatalogueServiceWeb('https://catalog.data.gov/csw')
</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">If I use (Python 3.6):</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p style="background: white; margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<b><span style="font-size:9.0pt; font-family:"Courier New"; color:navy">from </span>
</b><span style="font-size:9.0pt; font-family:"Courier New"; color:black">owslib </span>
<b><span style="font-size:9.0pt; font-family:"Courier New"; color:navy">import </span>
</b><span style="font-size:9.0pt; font-family:"Courier New"; color:black">csw </span>
<b><span style="font-size:9.0pt; font-family:"Courier New"; color:navy">as </span>
</b><span style="font-size:9.0pt; font-family:"Courier New"; color:black">csw<br>
<br>
c = csw.CatalogueServiceWeb(</span><b><span style="font-size:9.0pt; font-family:"Courier New"; color:teal">'https://catalog.data.gov/csw'</span></b><span style="font-size:9.0pt; font-family:"Courier New"; color:black">)<br>
c.getrecords2(</span><span style="font-size:9.0pt; font-family:"Courier New"; color:#660099">maxrecords</span><span style="font-size:9.0pt; font-family:"Courier New"; color:black">=</span><span style="font-size:9.0pt; font-family:"Courier New"; color:blue">20</span><span style="font-size:9.0pt; font-family:"Courier New"; color:black">)<br>
</span><span style="font-size:9.0pt; font-family:"Courier New"; color:navy">print</span><span style="font-size:9.0pt; font-family:"Courier New"; color:black">(c.records)</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">I get a result (eventually ~ the service seems quite slow).</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">I’ve tried running a query but it seems to be taking forever to return</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">James</span><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"></span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<b><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri",sans-serif"> OWSLib-users [mailto:owslib-users-bounces@lists.osgeo.org]
<b>On Behalf Of </b>Davide Muraro<br>
<b>Sent:</b> 01 June 2017 12:44<br>
<b>To:</b> owslib-users@lists.osgeo.org<br>
<b>Subject:</b> [OWSLib-users] CatalogueServiceWeb and data.gov exception</span></p>
</div>
</div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
 </p>
<div id="divtagdefaultwrapper">
<p><span style="font-family:"Calibri",sans-serif; color:black">Dear All,</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">I was doing some tests using CatalogueServiceWeb and the data.gov CSW.</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">Basically doing something like:</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">from owslib.csw import CatalogueServiceWeb</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">from owslib.fes import PropertyIsEqualTo, PropertyIsLike, BBox</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">csw = CatalogueServiceWeb('http://catalog.data.gov/csw?service=CSW&version=2.0.2&request=GetCapabilities')</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">query = PropertyIsEqualTo('csw:AnyText', 'map')</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">csw.getrecords2(constraints=[query], maxrecords=20)</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">print(csw.records)</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">i got:</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
</div>
<div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">*python3.5/site-packages/owslib/csw.py in getrecords2(self, constraints, sortby, typenames, esn, outputschema, format, startposition, maxrecords, cql, xml, resulttype)</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">    380 </span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">    381             # process search results attributes</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">--> 382             val = self._exml.find(util.nspath_eval('csw:SearchResults', namespaces)).attrib.get('numberOfRecordsMatched')</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">    383             self.results['matches'] = int(util.testXMLValue(val, True))</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">    384             val = self._exml.find(util.nspath_eval('csw:SearchResults', namespaces)).attrib.get('numberOfRecordsReturned')</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">AttributeError: 'NoneType' object has no attribute 'attrib'</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
</div>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">Ideas?</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black">D</span></p>
</div>
<div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
</div>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;">
<span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
</div>
</div>
<hr>
<small>This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material
 supplied to NERC may be stored in an electronic records management system</small>.
<hr>
</div>
</div>
</div>
</div>
</div>
</body>
</html>