Author Topic: Parsing the XML data from wunderground.com  (Read 2837 times)

0 Members and 1 Guest are viewing this topic.

Offline grayarea

  • Member
  • *
  • Posts: 1
    • Shepherds Lair Observatory
Parsing the XML data from wunderground.com
« on: September 26, 2016, 07:28:24 PM »
Hi folks,
Here at Shepherds Lair Observatory, we've been slowly getting the telescopes fully automated, allong with the roof, the camera's the calibration lights, etc.
http://siderealtechnology.com/SLO/index.html

Our WXStation ID is KORESTAC11
https://www.wunderground.com/personal-weather-station/dashboard?ID=KORESTAC11#history

We've been using our Ambient weather station (WS-1001-WIFI) for a couple of years.
As far as I can tell, there's no way to link in real time to this weather station.
There is new software called EasyWeather, but there's no way to link to it either.
This means our only option is to read the WUnderground website, and parse the data.

We live in the country, and our internet is slow.  So, the link below is the only way I could figure out how to read the most current data from the WUnderground website.  Here's the link for our station:
https://api.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KORESTAC11&format=XML

Unfortunately, this XML data comes back with just one reading at 5 minutes after midnight, then every 5 minutes it gets longer and longer. By the time it's midnight again, the file is about 700K long.  This is much longer than I would like to read every 5 minutes, especially with our limited bandwidth!

I would like to know a way to just read the most recent reading.

I see there's some flash things, but that comes back as a short movie, also, an image, but I don't want to have to character recognize the image you can get back, and also, the main website is even longer than 700k.

Does anyone have any idea's?

Thanks!  Dan Gray.
P.S.
Here's one of the latest images that the automation took all by itself.  This is an all night process for just one image:
http://siderealtechnology.com/M31_SLO.jpg

P.S.S.
Here's a typical reading.  It's only 2400 bytes long. As you can see, it would be easy for our software to parse the XML, and get the temperature, humidity, wind, rain, etc. 
But 288 of the 2400 byte records would be too much for our slow bandwidth.

   <current_observation>
      <credit>Weather Underground Personal Weather Station</credit>
      <credit_URL>http://wunderground.com/weatherstation/</credit_URL>
        <image>
            <url>http://icons.wunderground.com/graphics/bh-wui_logo.gif</url>
            <title>Weather Underground</title>
            <link>http://wunderground.com/weatherstation/</link>
        </image>
      <location>
         <full>Shepherd's Lair Observatory, Estacada, OR, OR</full>
         <neighborhood>Shepherd's Lair Observatory</neighborhood>
         <city>Estacada</city>
         <state>OR</state>
         <zip>97023</zip>
         <latitude>45.32517624</latitude>
         <longitude>-122.31649780</longitude>
         <elevation>699 ft</elevation>
      </location>
      <station_id>KORESTAC11</station_id>
      <station_type></station_type>
      <observation_time>Last Updated on September 25, 12:10 AM PDT</observation_time>
      <observation_time_rfc822>Sun, 25 Sep 2016 07:10:00 GMT</observation_time_rfc822>
      <weather></weather>
      <temperature_string>51.8 F ( C)</temperature_string>
      <temp_f>51.8</temp_f>
      <temp_c>11.0</temp_c>
      <relative_humidity>98</relative_humidity>
      
      <wind_string>Calm</wind_string>
      
      <wind_dir>SSE</wind_dir>
      <wind_degrees>153</wind_degrees>
      <wind_mph>0.0</wind_mph>
      <wind_gust_mph>0.0</wind_gust_mph>
      <pressure_string>30.10" (1019.2 mb)</pressure_string>
      <pressure_mb>1019.2</pressure_mb>
      <pressure_in>30.10</pressure_in>
      <dewpoint_string>51.3 F (10.7 C)</dewpoint_string>
      <dewpoint_f>51.3</dewpoint_f>
      <dewpoint_c>10.7</dewpoint_c>
      
      <heat_index_string></heat_index_string>
      <heat_index_f></heat_index_f>
      <heat_index_c></heat_index_c>
      
      
      <windchill_string></windchill_string>
      <windchill_f></windchill_f>
      <windchill_c></windchill_c>
      
      <solar_radiation>0.00</solar_radiation>
      <UV>0</UV>
      <precip_1hr_string>0.00 in (0.0 mm)</precip_1hr_string>
      <precip_1hr_in>0.00</precip_1hr_in>
      <precip_1hr_metric>0.0</precip_1hr_metric>
      <precip_today_string>0.00 in (0.0 mm)</precip_today_string>
      <precip_today_in>0.00</precip_today_in>
      <precip_today_metric>0.0 mm</precip_today_metric>
      <history_url>http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KORESTAC11</history_url>
      <ob_url>http://www.wunderground.com/cgi-bin/findweather/getForecast?query=45.32517624,-122.31649780</ob_url>
   </current_observation>











Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Parsing the XML data from wunderground.com
« Reply #1 on: September 26, 2016, 07:33:37 PM »
Yes, you can use this - one data set = one line.

Just always change the day/month/year in the URL to get the day you want

https://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KORESTAC11&month=01&day=01&year=2016&format=1

 

anything