METAR/TAF info on web page

gprellwitz

Touchdown! Greaser!
Joined
Jun 19, 2005
Messages
12,762
Location
Romeoville, IL
Display Name

Display name:
Grant Prellwitz
Okay, there is (hopefully) a simple solution to this.

I want to include the METAR and TAF from a particular airport on a web page.

I can get the data I need via anonymous FTP directly from NWS, but the server that hosts my site doesn't permit outbound FTP (or HTTP) connections without a static IP, which I don't currently have.

It seems that the alternative would be to make a connection from the user's browser. I suppose that I could do something with frames, but I'm trying to avoid them. Is there something I can do with JavaScript of the like that will allow me to do this? My goal is a quick, "universal", lightweight solution. So, while I could use a Java applet or the like, I'd rather not go to that extreme.

How do others, like airnav, etc. do it? Are they all doing it server-side? Maybe I'll just have to convince the site owner it's worth $30/year to get a static IP.
 
I can get the data I need via anonymous FTP directly from NWS, but the server that hosts my site doesn't permit outbound FTP (or HTTP) connections without a static IP, which I don't currently have.
This doesn't really make sense at all. What makes you think you can't do it? Can you run PHP or Perl? You could make the connection using either.

I
It seems that the alternative would be to make a connection from the user's browser. I suppose that I could do something with frames, but I'm trying to avoid them. Is there something I can do with JavaScript of the like that will allow me to do this? My goal is a quick, "universal", lightweight solution. So, while I could use a Java applet or the like, I'd rather not go to that extreme.
Don't even bother. This is something that needs to be done server-side. It would be pretty halfass to try client side.

How do others, like airnav, etc. do it? Are they all doing it server-side? Maybe I'll just have to convince the site owner it's worth $30/year to get a static IP.
I would have to see how the FTP feed is setup. They either open a connection with each page load and download the information or they script a download of everything every 5 minutes and dump that into a database.

If it were me I would script a download of all the data every 5 minutes. This way I could build a database of historical weather information. Client page loads would be fast because they would just be querying the database. Of course on a small site this is going to eat up some bandwidth that isn't needed. If you are only wanting one airport--once again this is a waste. If the traffic is low and it's only one airport you might just make it download it on each page load. Or you could store the data in a file or database and only redownload after 5 minutes. This would be the "internet friendly" way of doing it.

The static IP thing does not make any sense. There is no technical reason for it. It is a *huge* no-no to host web sites on static IP addresses. This is not a reason that requires one and claiming it does is WAY against ARIN guidelines.
 
Last edited:
This doesn't really make sense at all. What makes you think you can't do it? Can you run PHP or Perl? You could make the connection using either.
I've already written a perl program that should do it. I get a timeout:
Code:
500 LWP::Protocol::MyFTP: connect: Connection timed out
I called support, and they said that port 21 is blocked outbound by their firewall. They need to set up a static IP address so they can open it in the firewall. At least, that's how I rationalized what little information he was giving me.
If it were me I would script a download of all the data every 5 minutes. This way I could build a database of historical weather information. Client page loads would be fast because they would just be querying the database.

The static IP thing does not make any sense. There is no technical reason for it. It is a *huge* no-no to host web sites on static IP addresses. This is not a reason that requires one and claiming it does is WAY against ARIN guidelines.
I didn't get the sense that I was talking to a rocket scientist on the phone, though they did make a point of mentioning that their support personnel were in the US. :yes: Maybe I'll call back after the holiday and talk to a supervisor. Could you give me info on the ARIN guidelines that I could use? I haven't had to deal with hosting issues for many years, so this is unknown territory for me.

Oh, to make me feel even safer, he asked me for the site master password during the initial data-gathering phase, even though I had provided him with a web-created trouble ticket number.:hairraise:
 
Last edited:
I think--you should just get a new web host.

Is this a shared server? Basically multiple clients on one server? If so-- a static IP address isn't going to do anything for you. Your outbound connection is going to go through the default gateway and interface. They could give you an ip address specific to your virtual host--but your perl call isn't going to use that interface. Therefore it'll make no difference.

It is understandable that they would block outbound connections on port 21. I don't see how a static IP is going to fix this. Even if they do some technical trickery, I wouldn't pay them for one. Really--you just need to find a host that is a little more open to dynamic, custom, websites.

If you want full control, and the ability to do cool things like this, you pretty much need to step up to a virtual server.

Your last option..Would be to find a way to do it over HTTP. If you go to: http://adds.aviationweather.gov/met...on&hoursStr=most+recent+only&submitmet=Submit You get the latest metar for KLNK. You could do it this way--would just have to parse the returned HTML for the metar txt. If I was in a hurry--I'd probably do something like that.
 
Last edited:
If you want full control, and the ability to do cool things like this, you pretty much need to step up to a virtual server.
This is one of those situations where the previous "webmaster" has departed the scene, and I'm left with what he had set up. I think we're paid through April of 2009. I have no idea of the technical specs, other than the general info that the hosting company posts on their website. FBOs don't make a whole lot of money, so I'm disinclined to throw away stuff they've already purchased.

Jesse, if it's alright, I'll PM you the hosting company info and ask for your recommendation.
 
Grant.. I suspect you didnt see my above edit. HTTP might be the best way to do this on your current host.
 
Grant.. I suspect you didnt see my above edit. HTTP might be the best way to do this on your current host.
Yeah, we overlapped. Unfortunately, they said that HTTP would be the same situation as FTP, meaning a static IP. I admit that sounds suspect, but, presuming it's true, I'd have to do the fetch, parse, and display all from within the end-user's browser. I really don't like that solution. :no:
 
Yeah, we overlapped. Unfortunately, they said that HTTP would be the same situation as FTP, meaning a static IP.

Do you have shell access?

It's really not an option to do it client side. FTP or HTTP (FTP for sure). You'd almost need a java applet and you would throw a bunch of red flags with software firewalls. It's possible that you might be able to pull something off with Java script (dont know much about it) but its not going to be very cross platform.
 
Last edited:
I'll see if I can think something up that'll work...
 
This might do it for you. Try putting this on your HTML page where you want the metar:
Code:
<script type="text/javascript" src="http://jesseangell.com/forums/grantweather/metar.php?id=KLNK"> </script>
Change KLNK to the identifier of your choice. This is a PHP script on my server that downloads the metar and outputs it in a javascript print. Obviously dependent on my server--but it should be around for a long long time.
 
This might do it for you. Try putting this on your HTML page where you want the metar:
Code:
<script type="text/javascript" src="http://jesseangell.com/forums/grantweather/metar.php?id=KLNK"> </script>
Change KLNK to the identifier of your choice. This is a PHP script on my server that downloads the metar and outputs it in a javascript print. Obviously dependent on my server--but it should be around for a long long time.
Jesse, yes, that works, and THANKS! But it's not something that I feel comfortable using long term, for a multitude of reasons.

The URL that's calling it is http://www.aandmaviation.com/weather.html
and you can see that there's a definite delay as it heads out to your server to get the info. If you could leave it for a little while so I can show the FBO I'd appreciate it. I'm going to try to persuade them to either get the current hosting working to permit us to do this on our own or to switch hosting companies. I think there was a thread on them recently...
 
Jesse, yes, that works, and THANKS! But it's not something that I feel comfortable using long term, for a multitude of reasons.
Understandable. I wouldn't want to either. In this case I really wouldn't want to since you are doing a service for another business.
gprellwitz said:
and you can see that there's a definite delay as it heads out to your server to get the info. If you could leave it for a little while so I can show the FBO I'd appreciate it. I'm going to try to persuade them to either get the current hosting working to permit us to do this on our own or to switch hosting companies. I think there was a thread on them recently...
I don't have any noticeable delay. But there is bound to be some as it must first contact my server, which contacts weather.noaa.gov, which returns a response.

I'll leave it working. I can't promise you it'll always work. But it shouldn't be going anywhere in the foreseeable future.
 
Here's a page that will generate the code for a widget. Ctrl-C the code (copy it) and drop it into your web page. Current Approach Plates in a very nice tabbed structure as well a METARs and/or TAFs for any airport(s) of your choice.

To see an example, look at www.gwinnettcountyairport.com. On the home page on the right. Also, Frank is using it for some of the trip airports on www.160knots.com.

This is brand new so please report any problems or volunteer suggestions.

Here's the page: www.flightcentral.net/widgets
 
Here's a page that will generate the code for a widget. Ctrl-C the code (copy it) and drop it into your web page. Current Approach Plates in a very nice tabbed structure as well a METARs and/or TAFs for any airport(s) of your choice.

To see an example, look at www.gwinnettcountyairport.com. On the home page on the right. Also, Frank is using it for some of the trip airports on www.160knots.com.

This is brand new so please report any problems or volunteer suggestions.

Here's the page: www.flightcentral.net/widgets
Cool, there's some great stuff here!

First, your sample widget code taught me how I could actually use the iframe to just ftp it directly from the NOAA site if I don't want any additional formatting.
Simply:
Code:
[B]<iframe src="ftp://tgftp.nws.noaa.gov/data/observations/metar/stations/KLOT.TXT" scrolling="auto" frameborder="0" width="470" height="60">[/B][B]</iframe>[/B]
I like, though, how you use the colored buttons to quickly identify VFR/IFR conditions. (I presume that they're green for VFR. Right now, we're showing:
14006KT 1/4SM FZFG OVC002 M01/M02
A couple of suggestions, though, and one bug.

The suggestions are
1) to suppress tabs in the Approach widget if there's nothing in them and
2) to present the airports in the order in which they are specified instead of alphabetizing them. That way the user can specify them in order of preference and see the results that way.
3) Default to scroll="auto" instead of "no", since the latter can cause information to be silently truncated. Since TAFs can get long, that's not a good thing.

The bug is that the code generator for the WeatherApproachWidget generates a WeatherWidget instead.

I still think that I'd rather have full control over all this myself by doing it server-side, but, absent that, this solution will serve very nicely. Thanks!
 
Grant--I would *REALLY* avoid using FTP. It's slow--it'll cause problems depending on people's browser and firewall.

Use this instead:
Code:
http://weather.noaa.gov/pub/data/observations/metar/stations/KLOT.TXT
 
Grant--I would *REALLY* avoid using FTP. It's slow--it'll cause problems depending on people's browser and firewall.

Use this instead:
Code:
http://weather.noaa.gov/pub/data/observations/metar/stations/KLOT.TXT
Jesse, Thanks! I hadn't come across those links before. I agree, I'd much rather not use ftp, except to do it from my server.
 
Thanx much for your suggestions and the bug report, Grant! We're going to continue to polish these widgets up and you had some good ideas.

Oh, any you are correct about the colored buttons. Red=IFR, Yellow=MVFR, and Green=VFR. Hover the mouse button and it tells you.

If you or anyone else drops the Plates or Weather into their sites, please post the links so we can take a look.

- Russ
 
Last edited:
Grant--I would *REALLY* avoid using FTP. It's slow--it'll cause problems depending on people's browser and firewall.

Use this instead:
Code:
http://weather.noaa.gov/pub/data/observations/metar/stations/KLOT.TXT

I'll just note that this is a real problem. All external FTP sites are blocked at work. Makes it a royal pain when committees use an FTP site for sharing files.
 
Back
Top