[quote=“Duffanator”]Here’s one that I modified to get weather information from weather.com. You can see if that works for you.
[code]def update():
import system
import xml.dom.minidom
# Get Zip Code
zip = system.tag.read("[Client]Weather/Zip").value
url = "http://wxdata.weather.com/wxdata/weather/local/%d?cc=*&dayf=5" % zip
try:
response = system.net.httpGet(url)
# Put it in the dom
dom = xml.dom.minidom.parseString(response)
for node in dom.getElementsByTagName("loc"):
system.tag.write("[Client]Weather/City State", node.getElementsByTagName("dnam")[0].firstChild.nodeValue)
# Get the tag for current conditions
for node in dom.getElementsByTagName("cc"):
system.tag.write("[Client]Weather/Current/Temp", node.getElementsByTagName("tmp")[0].firstChild.nodeValue)
humid = node.getElementsByTagName("hmid")[0].firstChild.nodeValue + " %"
system.tag.write("[Client]Weather/Current/Humidity", humid)
for subNode in node.getElementsByTagName("wind"):
speed = subNode.getElementsByTagName("s")[0].firstChild.nodeValue
direction = subNode.getElementsByTagName("t")[0].firstChild.nodeValue
windInfo = direction + " at " + speed + " mph"
system.tag.write("[Client]Weather/Current/Wind", windInfo)
system.tag.write("[Client]Weather/Current/Date", node.getElementsByTagName("lsup")[0].firstChild.nodeValue)
system.tag.write("[Client]Weather/Current/Icon", node.getElementsByTagName("icon")[0].firstChild.nodeValue)
system.tag.write("[Client]Weather/Current/Condition", node.getElementsByTagName("t")[0].firstChild.nodeValue)
# Get the tags for the next 2 days forecast
day = 0
for node in dom.getElementsByTagName("dayf"):
for node in dom.getElementsByTagName("day"):
if day > 0:
system.tag.write("[Client]Weather/Day %d/Day" % day, node.getAttribute("t"))
system.tag.write("[Client]Weather/Day %d/Low" % day, node.getElementsByTagName("low")[0].firstChild.nodeValue)
system.tag.write("[Client]Weather/Day %d/High" % day, node.getElementsByTagName("hi")[0].firstChild.nodeValue)
for partNode in node.getElementsByTagName("part"):
if partNode.getAttribute("p") == "d":
if day > 0:
system.tag.write("[Client]Weather/Day %d/Icon" % day, partNode.getElementsByTagName("icon")[0].firstChild.nodeValue)
system.tag.write("[Client]Weather/Day %d/Condition" % day, partNode.getElementsByTagName("t")[0].firstChild.nodeValue)
day = day + 1
system.tag.write("[Client]Weather/Live", 1)
del response
del dom
print "Weather Update Successful!"
except:
system.tag.write("[Client]Weather/Live", 0)
print "Weather Update Failed!"[/code][/quote]
Sorry I am a little slow on the uptake. What would the UDT structure look like?