Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

ec-forecast V5.00 released -- uses XML instead of EC page scraping

Discussion of Ken True's web site templates

Moderator: saratogaWX

User avatar
saratogaWX
Posts: 835
Joined: Wed May 06, 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows XP SP3
Location: Saratoga, CA, USA
Contact:

ec-forecast V5.00 released -- uses XML instead of EC page scraping

Postby saratogaWX » Wed Sep 27, 2017 7:29 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

Return to “Saratoga Templates”

Who is online

Users browsing this forum: No registered users and 2 guests