extract string from body of text 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

LOW-MODERATE

This is the cut down version of the full body of text that has the data i need to get from rss feed;

&lt;p&gt;Fire Danger Ratings&lt;br /&gt;Bureau of Meteorology forecast issued at: Mon, 4 Nov 2013 05:30 AM&lt;/p&gt;

&lt;p&gt;Central: LOW-MODERATE&lt;/p&gt;


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[0].description
print (data)
print('---------')

getdate = re.compile('forecast issued at: (.*?)&lt;/p&gt;')
getrating = re.compile('&lt;p&gt;Central: (.*?)&lt;/p&gt;')

m = getdate.search(data)
n = getrating.search(data)

print(m.group(1))
print(n.group(1))


This is the FULL data that is returned;

 &lt;p&gt;Total Fire Ban Status&lt;br /&gt;Today, Mon, 4 Nov 2013 is &lt;strong&gt;not&lt;/strong&gt; currently a day of Total Fire Ban in the &lt;strong&gt;Central (includes Melbourne and Geelong)&lt;/strong&gt; fire district.&lt;/p&gt;&lt;p&gt;Fire Danger Ratings&lt;br /&gt;Bureau of Meteorology forecast issued at: Mon, 4 Nov 2013 05:30 AM&lt;/p&gt;&lt;p&gt;Central: LOW-MODERATE&lt;/p&gt;&lt;/p&gt;&lt;img alt="" border="0" src="http://www.cfa.vic.gov.au/images/fdr/central/low-moderate.gif" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img alt="" height="22" src="http://www.cfa.vic.gov.au/images/fdr/tfb_icon_msg.gif" width="22" /&gt; Displays when Total Fire Ban in force&lt;br /&gt;&lt;span&gt;&lt;a href="http://www.cfa.vic.gov.au/warnings-restrictions/restrictions-during-the-fire-danger-period"&gt;Restrictions may apply&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

---------
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?
You can do the whole thing with a single regexp:

import re

data = """
&lt;p&gt;Fire Danger Ratings
&lt;br /&gt;Bureau of Meteorology 
forecast issued at: Mon, 4 Nov 2013 05:30 AM&lt;/p&gt;

&lt;p&gt;Central: LOW-MODERATE&lt;/p&gt;         
"""

rgx = re.compile("(forecast issued at: |&lt;p&gt;Central: )(.*?)&lt;/p&gt;")
results = rgx.findall(data)
print results[0][1]
print results[1][1]


Output:

$ python rss_parse.py
Mon, 4 Nov 2013 05:30 AM
LOW-MODERATE


If this only runs a time or two a day, pre-compiling the regex is not important. 

...
results = re.findall("(forecast issued at: |&lt;p&gt;Central: )(.*?)&lt;/p&gt;", data)
print results[0][1]
print results[1][1]


We can simplify how the result is handled:

...
[when, rating] = [x[1] for x in
                  re.findall("(forecast issued at: |&lt;p&gt;Central: )(.*?)&lt;/p&gt;",
                             data)]
print("%s\n%s" % (when, rating))