Author Topic: ec-forecast V5.00 released -- uses XML instead of EC page scraping  (Read 136 times)

0 Members and 1 Guest are viewing this topic.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6186
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
ec-forecast V5.00 released -- uses XML instead of EC page scraping
« on: September 27, 2017, 03:25:48 PM »
This version is a MAJOR rewrite of the script (originally released in 2006) and changes the way the data is acquired -- no longer will it be subject to the whims of the Environment Canada webmasters who seem to delight in minor tweaks to the page HTML.  Instead, this script relies on the XML data provided by the EC via http://dd.weather.gc.ca/citypage_weather/xml/ site, and that XML data format has been stable for many years.

The main issue to overcome was how to seamlessly convert the existing EC website URLs used in V1-V4 of the script to the XML data file URLs needed for the actual data.  That was solved by a new lookup table (ec-forecast-lookup.txt) that (along with a new function call) will do that conversion.  So, ec-forecast-lookup.txt is now REQUIRED to be in the same directory as the ec-forecast.php script for proper operation.

Some new features with this release:
1) the * indicator for abnormal temperature is back and appears after the Min or Max temperature in the icon display.
2) a new Averages and Extremes table is now produced (in $almanac string).
3) a new 24-hour hourly forecast table is now produced (in $forecast24h string).
4) new settings control the display of the Averages and Extremes and the 24-hour forecast table.  In Settings.php these can be used:

$SITE['ECshowConditions'] = true;  // set to false to disable Conditions display box
$SITE['ECshowAlmanac'] = true;    // set to false to disable Almanac (Averages/Extremes) display box
$SITE['ECshow24hour'] = true;      // set to false to disable 24-hour hourly forecast display box

In a calling script, the variables:

$doShowConditions, $doShowAlmanac, $doShow24hour will override the above.

The HTML for almanac is returned in $almanac and the 24-hour hourly forecast is returned in the $forecast24h string.

I'm hoping that the shift to using XML will put an end to the frequent updates to this script as we'll no longer depend on the raw HTML of the EC website :)

Standalone: download from the script page note: download ec-forecast-lookup.txt too!
Saratoga template: use the update tool page with a query for Base-Canada, Plugin-*, 27-Sep-2017

Thanks to all the testers who provided feedback with the V5.00 beta!!

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline DW7240

  • Senior Contributor
  • ****
  • Posts: 168
    • The Vicarage Weather Feed
Re: ec-forecast V5.00 released -- uses XML instead of EC page scraping
« Reply #1 on: September 27, 2017, 06:56:16 PM »
Hi Ken,

A big thank you again for all your hard work and dedication.  The current newly written ec-forecast is a massive improvement, the extra data is great.

A happy weather geek -  =D> =D> :lol:

Nick. dw7240.com.


Offline PaulMy

  • Forecaster
  • *****
  • Posts: 3617
    • KomokaWeather
Re: ec-forecast V5.00 released -- uses XML instead of EC page scraping
« Reply #2 on: September 27, 2017, 07:14:11 PM »
Thanks Ken, I have now removed the beta and using the new released.  Glad to have been some help in testing.

Enjoy,
Paul

 

anything