Trying to return the below values from an RSS feed. I have sorted out the RSS feed side of things but I am not sure if what I am doing is the best way to extract the data that I need. I have looked at beautifulsoup and regex's, re.search but not sure what is the best way to do this.
Values that I need; (both of these values change daily obviously)
4 Nov 2013
This is the cut down version of the full body of text that has the data i need to get from rss feed;
<p>Fire Danger Ratings<br />Bureau of Meteorology forecast issued at: Mon, 4 Nov 2013 05:30 AM</p> <p>Central: LOW-MODERATE</p>
My code to extract the rss feed and data at the moment;
import feedparser #https://wiki.python.org/moin/RssLibraries cfa_rss_url = "http://www.cfa.vic.gov.au/restrictions/central-firedistrict_rss.xml" d = feedparser.parse( cfa_rss_url ) #get the data from the first item only, as it is only updated daily. data = d.entries.description print (data) print('---------') getdate = re.compile('forecast issued at: (.*?)</p>') getrating = re.compile('<p>Central: (.*?)</p>') m = getdate.search(data) n = getrating.search(data) print(m.group(1)) print(n.group(1))
This is the FULL data that is returned;
<p>Total Fire Ban Status<br />Today, Mon, 4 Nov 2013 is <strong>not</strong> currently a day of Total Fire Ban in the <strong>Central (includes Melbourne and Geelong)</strong> fire district.</p><p>Fire Danger Ratings<br />Bureau of Meteorology forecast issued at: Mon, 4 Nov 2013 05:30 AM</p><p>Central: LOW-MODERATE</p></p><img alt="" border="0" src="http://www.cfa.vic.gov.au/images/fdr/central/low-moderate.gif" /></p><p><img alt="" height="22" src="http://www.cfa.vic.gov.au/images/fdr/tfb_icon_msg.gif" width="22" /> Displays when Total Fire Ban in force<br /><span><a href="http://www.cfa.vic.gov.au/warnings-restrictions/restrictions-during-the-fire-danger-period">Restrictions may apply</a></span></p> --------- Mon, 4 Nov 2013 05:30 AM LOW-MODERATE
As you can see my code returns the correct values atm but is this the most efficient way of doing this or should I be using another command?