I'm trying to parse the NOAA Weather RSS Feed. I've got my script pulling the entries just fine, but some of the fields are blank and I can't figure out why. It seems to be a problem with more complex data types in the feed. Here is the code:
url = 'http://alerts.weather.gov/cap/us.php?x=1'
feed = feedparser.parse(url)
print 'title: ', feed.entries[0].title
print 'cap_geocode: ', feed.entries[0].cap_geocode
print 'cap_event: ', feed.entries[0].cap_event
Here are the results from printing an entry:
title: Flood Watch issued June 18 at 5:00AM AKDT until June 21 at 4:00PM...
cap_geocode:
cap_event: Flood Watch
I can't figure out why cap_geocode is blank. Any idea? Here is the xml file with just one element. The feed actually pulls back 100s or entries, so I reduced it to just a small sample.
<feed
xmlns = 'http://www.w3.org/2005/Atom'
xmlns:cap = 'urn:oasis:names:tc:emergency:cap:1.1'
xmlns:ha = 'http://www.alerting.net/namespace/index_1.0'
>
<id>http://alerts.weather.gov/cap/us.atom</id>
<logo>http://alerts.weather.gov/images/xml_logo.gif</logo>
<generator>NWS CAP Server</generator>
<updated>2014-06-18T08:22:00-06:00</updated>
<author>
<name>w-nws.webmaster@noaa.gov</name>
</author>
<title>Current Watches, Warnings and Advisories for the United States Issued by the National Weather Service</title>
<link href='http://alerts.weather.gov/cap/us.atom'/>
<entry>
<id>http://alerts.weather.gov/cap/wwacapget.php?x=WY12515A62F544.WinterWeatherAdvisory.12515A71D320WY.RIWWSWRIW.8dcf1ff2519d541d79867824b0480d63</id>
<updated>2014-06-18T02:57:00-06:00</updated>
<published>2014-06-18T02:57:00-06:00</published>
<author>
<name>w-nws.webmaster@noaa.gov</name>
</author>
<title>Winter Weather Advisory issued June 18 at 2:57AM MDT until June 19 at 12:00AM MDT by NWS</title>
<link href='http://alerts.weather.gov/cap/wwacapget.php?x=WY12515A62F544.WinterWeatherAdvisory.12515A71D320WY.RIWWSWRIW.8dcf1ff2519d541d79867824b0480d63'/>
<summary>...WINTER WEATHER CONTINUES TO IMPACT THE WESTERN AND CENTRAL MOUNTAINS THROUGH MIDNIGHT.</summary>
<cap:event>Winter Weather Advisory</cap:event>
<cap:effective>2014-06-18T02:57:00-06:00</cap:effective>
<cap:expires>2014-06-19T00:00:00-06:00</cap:expires>
<cap:status>Actual</cap:status>
<cap:msgType>Alert</cap:msgType>
<cap:category>Met</cap:category>
<cap:urgency>Expected</cap:urgency>
<cap:severity>Minor</cap:severity>
<cap:certainty>Likely</cap:certainty>
<cap:areaDesc>Absaroka Mountains; Teton and Gros Ventre Mountains</cap:areaDesc>
<cap:polygon></cap:polygon>
<cap:geocode>
<valueName>FIPS6</valueName>
<value>056013 056017 056023 056029 056035 056039</value>
<valueName>UGC</valueName>
<value>WYZ002 WYZ012</value>
</cap:geocode>
<cap:parameter>
<valueName>VTEC</valueName>
<value>/O.CON.KRIW.WW.Y.0031.000000T0000Z-140619T0600Z/</value>
</cap:parameter>
</entry>
</feed>
Any help would be appreciated. Thanks
*Update I have verified that cap_geocode is a blank unicode string of length 0, not an object of some sort.