Author Topic: How to scrape WU data and use it in a php script  (Read 680 times)

0 Members and 1 Guest are viewing this topic.

Offline MikeWest

  • Member
  • *
  • Posts: 25
    • Observatory West
How to scrape WU data and use it in a php script
« on: December 23, 2017, 08:43:50 PM »
Hello,

I have an Ambient Weather WS-2902 that sends to WU, AW.net and weathercloud.  I am trying to put together a php based weather website from Saratoga or similar, however I cannot figure out how to scrape the data from my WU station ID and make it available to php?  I have searched, read many many pages, and not found anything that seems like it would work, short of buying something like Weather-Display software.  Is there anything out there that is free and works?

Thanks!
So many trees in NJ!


Offline sacreyweather

  • Echo Valley Weather
  • Forecaster
  • *****
  • Posts: 1631
    • Echo Valley Weather
Re: How to scrape WU data and use it in a php script
« Reply #1 on: December 23, 2017, 08:56:30 PM »
Check here:  Sandaysoft Home of CumulusMX software
CWOP: D2073, GR2AE, GR3, Cumulus, PWSweather,  CoCoRaHS: AR-SL-23  

Saline Weather on Twitter
Blitzortung Station 1387

Offline SteveFitz1

  • Forecaster
  • *****
  • Posts: 336
    • http://www.TylerTexasWeather.Com
Re: How to scrape WU data and use it in a php script
« Reply #2 on: December 23, 2017, 10:02:15 PM »
If you're simply wanting to "scrape" your own data from Wunderground, you should consder using a WU API to pull the information directly into PHP variables you can plug into your own webpage. https://www.wunderground.com/weather/api/d/docs?d=data/conditions#examples

You'll first need to get an API key from WU, then plug it in here along with your WU Station ID to see what information is provided:

http://api.wunderground.com/api/---Your WU API Key---/conditions/q/pws:---Your WU Station ID---.json

Steve

Offline MikeWest

  • Member
  • *
  • Posts: 25
    • Observatory West
Re: How to scrape WU data and use it in a php script
« Reply #3 on: December 23, 2017, 10:25:08 PM »
Thanks Steve, I do already have an API key, and using your sample below I have it spitting out the information, now I need to figure out how to push that into something usable by one of the templates. Do you know of a reliable way to translate the json information into an appropriate realtime.txt file?  It seems to me now that I would need a CRON job or equivalent running every so often to pull the info, a second job running right after to translate the info into a suitable realtime.txt file, then the normal template files would take over to display the information.

Thanks for your help!

If you're simply wanting to "scrape" your own data from Wunderground, you should consder using a WU API to pull the information directly into PHP variables you can plug into your own webpage. https://www.wunderground.com/weather/api/d/docs?d=data/conditions#examples

You'll first need to get an API key from WU, then plug it in here along with your WU Station ID to see what information is provided:

http://api.wunderground.com/api/---Your WU API Key---/conditions/q/pws:---Your WU Station ID---.json

Steve
So many trees in NJ!


Offline SteveFitz1

  • Forecaster
  • *****
  • Posts: 336
    • http://www.TylerTexasWeather.Com
Re: How to scrape WU data and use it in a php script
« Reply #4 on: December 23, 2017, 10:32:07 PM »
PM me with your email address and I'll send you a script I use to pull info.

Steve

Offline MikeWest

  • Member
  • *
  • Posts: 25
    • Observatory West
Re: How to scrape WU data and use it in a php script
« Reply #5 on: December 23, 2017, 10:36:29 PM »
I just PM'd you, thanks!

PM me with your email address and I'll send you a script I use to pull info.

Steve
So many trees in NJ!