2

I'm trying to parse data from a website and cannot print the data.

import xml.etree.ElementTree as ET
from urllib import urlopen

link = urlopen('http://weather.aero/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&stationString=KSFO&hoursBeforeNow=1')

tree = ET.parse(link)
root = tree.getroot()

data = root.findall('data/metar')
for metar in data:
    print metar.find('temp_c').text
1
  • How would I go about parsing the sky condition? 1) The string is conditional based on the weather so it/s always changing. 2) It's not like temp_c and temp_f, all the sky conditions are in one field name. Commented Oct 23, 2012 at 6:20

1 Answer 1

2

It is case sensitive:

data = root.findall('data/METAR')
Sign up to request clarification or add additional context in comments.

1 Comment

@Savvis If this answers your question, you should mark it as the accepted answer (meta.stackoverflow.com/faq#howtoask)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.