Author Topic: how to get weatherlink site to display data in XML or JSON instead of HTML.  (Read 3680 times)

0 Members and 1 Guest are viewing this topic.

Offline fun2kite

  • Member
  • *
  • Posts: 2
Hi all,

I am new here and I have a question. Sorry if this was already answered, but I could not find it when searching the forum.
Here is a typical link to a weather station. This happens to be in Singapore, but my question is generic.
http://www.weatherlink.com/user/constantwind/index.php?view=main&headers=0

If you click the link, you'll see data in HTML format.
Is it possible to reformat the URL with some other parameters to make data come back as XML or JSON.
Maybe weather link has SOAP or REST API? 

Please note, I do not own this or any other weather station. I just really want to know when wind speed is increasing so I could go windsurf or kitesurf.
So I thought I would write a program to watch the info for me. I guess I could parse the HTML, but if there was an easy way to get XML, I would rather much prefer it.

Thank you all for help.

Regards,

-D.

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Hi,
Im not sure how weatherlink works, but either way, even if there was a possibility of data export as JSON or XML, since you want to use someone else´s site, I cannot think of how you could get that. Probably the only way would be parsing the HTML and by preg_match functions extract whatever data you need, which on the other hand isnt so difficult to do and if you only want to do it for personal use I dont see any major problem with it.

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Hi all,

I am new here and I have a question. Sorry if this was already answered, but I could not find it when searching the forum.
Here is a typical link to a weather station. This happens to be in Singapore, but my question is generic.
http://www.weatherlink.com/user/constantwind/index.php?view=main&headers=0

If you click the link, you'll see data in HTML format.
Is it possible to reformat the URL with some other parameters to make data come back as XML or JSON.
Maybe weather link has SOAP or REST API? 

Please note, I do not own this or any other weather station. I just really want to know when wind speed is increasing so I could go windsurf or kitesurf.
So I thought I would write a program to watch the info for me. I guess I could parse the HTML, but if there was an easy way to get XML, I would rather much prefer it.

Thank you all for help.

Regards,

-D.
The link to your data needs the password you use at WL.com to change your credentials
http://www.weatherlink.com/user/constantwind/index.php?view=main&headers=1
That is the login at the far right.

Then you vcan use this URL to fetch the latest data
http://www.weatherlink.com/xml.php?user=constantwind&pass=*********
For the *********  you set your password

It works OK. These are some of the wind values returned:
Code: [Select]
<wind_degrees>219</wind_degrees>
<wind_dir>Southwest</wind_dir>
<wind_kt>0</wind_kt>
<wind_mph>0</wind_mph>

<wind_day_high_mph>9</wind_day_high_mph>
<wind_day_high_time>2:58pm</wind_day_high_time>

<wind_ten_min_avg_mph>2</wind_ten_min_avg_mph>

Wim