Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import xml.parsers.expat as expat
- wxVars = {}
- def weathervarshandler(name, attributes):
- if (name != "variable"):
- return
- wxVars[attributes["var"]] =attributes["value"]
- def main():
- wxUrl = "http://www.wrh.noaa.gov/mesowest/getobextXml.php?sid=KFAT&num=1"
- wxReq = requests.get(wxUrl)
- wxXml = wxReq.text
- wxParse = expat.ParserCreate()
- wxParse.StartElementHandler = weathervarshandler
- wxParse.Parse(wxXml, 1)
- for i in wxVars:
- print(i)
- print(wxVars[i])
- if (__name__ == "__main__"):
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement