Ok maybe this has been asked but I couldn’t find it.
So I have been running the weather script for awhile and then it stopped working. I believe this was due to yahoo changing. But i am wondering what is a new way to get the weather?
Thanks
Ok maybe this has been asked but I couldn’t find it.
So I have been running the weather script for awhile and then it stopped working. I believe this was due to yahoo changing. But i am wondering what is a new way to get the weather?
Thanks
Weather Underground has an API that’s free to use for low volumes of request (it just requires registration) and it can return XML data just as Yahoo Weather used to.
Here’s one that I modified to get weather information from www.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=“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?
They should be client tags and be structured like this:
[attachment=0]WeatherTagStructure.jpg.jpg[/attachment]
Hi all!
I know this is not a recent thread, but I’m trying to find details for the API to wxdata.weather.com and can’t seem to find it via Google.
Anyone got a link to a page where I can find out what the various tags are the API provides?
Thanks,
Mike
Well this; (weather channel API), points you to this; (weather underground API), which says the free public API has been shutdown.
IBM owns both companies, and offers the data for a fee if you’re interested…
https://openweathermap.org/current has a free API service then pay for more data and functions.