Filtering data from

I am trying to use the example in the manual for and I am unable to figure out the correct expression and match to pull the data values I need. I am able to reach the page and get the string of info back but I am to get the information I need out of it.

The data I need is coming back in this format Value

I think this topic may help you out.

Your post helped but I am still screwing up something somewheres.

A gives me <temp_f>51.0</temp_f> <r_humid>99</r_humid>

My script is to extract the values from that is [code]response =“”)

import Python’s regular expression library

import re

NOTE - if you’ve never seen regular expressions before, don’t worry, they look

confusing even to people who use them frequently.

pattern = re.compile(’.?<.?>(.?)</.?>’, re.DOTALL)

match = pattern.match(response)

if match:

subText =

temp_f = re.compile(’.?temp_f"(.?)"’).match(subText).group(1)

r_humid = re.compile(’.?r_humid"(.?)"’).match(subText).group(1)

print "Temperature: ", temp_f

print "Humidity: ", r_humid


print ‘No Data’[/code]

Only part that’s working so far is the print 'No Data" :smiley:

Could you post what gets returned from the httpGet? That might let me wrap my head around it a little better.

EDIT: Never mind. I need more coffee… :laughing:

Let’s try simplifying a bit.

re.findall will return a list of values:


import re
pattern = re.compile(’.?<.?>(.?)</.?>’, re.DOTALL)

match=re.findall(pattern, response)
print “temp_f:”, match[0]
print “r_humid:”, match[1]

That worked!