cloudy

Author Topic: PHP Extraction of WD Avg/Ext HTM Files  (Read 43080 times)

0 Members and 1 Guest are viewing this topic.

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
PHP Extraction of WD Avg/Ext HTM Files
« on: December 22, 2007, 08:37:15 PM »
The source code for the extraction PHP code that I used to read an existing Avg/Ext htm file (i.e. December2007.htm), is now available.

Basically, it reads the Avg/Ext file, strips out the HTML (actually ignore it) and then sets up some tables for each day with CSS tags that allow you to pretty it up.

Note:
This version of the script will not work with the newer format of the Avg/Ext html file.  See below for a different link:

Scripts Page:
http://www.tnetweather.com/tws-avgext-script.php

It should continue to work after the current bug with the no ending tag for the <FONT stuff that is currently in it as long as the fix is consistent with how the other HTML is used.  If not, I will update it after it gets fixed.

One will need to point to the files they want, where they are located etc... and might need some tweaking.

Current working version of this script updated by Mike Challis:

http://www.weather-watch.com/smf/index.php/topic,28547.msg250037.html#msg250037
« Last Edit: April 11, 2008, 02:47:37 PM by TNETWeather »

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jwwd

  • Posts: 3,545
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #1 on: December 22, 2007, 09:12:52 PM »
Hi Kevin

I just tried your script - but canīt get the formatting to work:

http://www.buskelundtoften.dk/vejret/avgextract.php

http://www.buskelundtoften.dk/vejret/sample.php

Best regards,

Henrik

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #2 on: December 22, 2007, 09:31:56 PM »
No way to provide any assistance without having a clue where you are pointing at for the data.

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,220
  • Mauston, WI, USA
    • Juneau County Weather
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #3 on: December 22, 2007, 09:35:00 PM »
Looking at the source, you seem to be missing the <table> and </table>  tags.

- Jim

 Home of NSLog NexStorm Lightning Data Manager

Offline jwwd

  • Posts: 3,545
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #4 on: December 22, 2007, 09:37:10 PM »
No way to provide any assistance without having a clue where you are pointing at for the data.

Hi Kevin

Ups - sorry - im pointing at the www.buskelundtoften.dk/vejret/vejrdata/December2007.htm

Best regards,

Henrik

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #5 on: December 22, 2007, 09:39:31 PM »

Won't work with non-english tags.  It looks for Engish tags to know when and where to put the data.

Look at the data arrays at the bottom.  Will most likely need a lot of tweaking.

   $parts = array(
        array("Daily rain totals",0),
        array(". on day",0),
        array("Average ",3),
        array("Rainfall for month",4),
        array("Rainfall for year ",4),
        array("Maximum rain per minute",5),
        array("Maximum temp",3),
        array("Minimum temp",3),
        array("Maximum pressure",3),
        array("Minimum pressure",3),
        array("Maximum windspeed",3),
        array("Minimum guest",4),
        array("Maximum heat index",4),
        array("Minimum humi",3),
        array("Maximum humi",3),
        array("Growing degrees days",4),
    );
   
    // String, action 1 = skip 0 = print 2 = print blank, level, needpart
   
    $extracts = array (
        array("<pre>",1,1,0),
        array("daily report for ",1,0,1),
        array("font",1,0,0),
        array("pre",1,0,0),
        array("<hr>",1,2,0),
        array("-------",2,0,0),
        array("extremes for the month",1,3,1),
        array("extremes for day :",1,0,1),
    );

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jwwd

  • Posts: 3,545
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #6 on: December 22, 2007, 09:42:59 PM »
Hi again Kevin

Oh yes - of course - i will give it a try.

Thanks for your reply.

Best regards,

Henrik

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jhobby

  • Posts: 76
  • Silver Cliff, Colorado, USA
    • Silver Cliff, Colorado Weather
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #8 on: December 23, 2007, 02:31:45 AM »
Kevin, as usual Very Nice script,tried it out :

http://hobbyweather.com/avg.php

All I have to do is come up with a .gif image for it ?

Thank You.-Jeff

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #9 on: December 23, 2007, 02:35:45 AM »
Ideally, you would add this to your website current style and change the colors to match.

In your case, it would use your weather websites, current top bar as the title area. and you would use colors that match the style you have there.

You would then have a menu item pointing to that "page"

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jhobby

  • Posts: 76
  • Silver Cliff, Colorado, USA
    • Silver Cliff, Colorado Weather
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #10 on: December 23, 2007, 02:44:23 AM »
Kevin, Yes I am not very good at this yet, I have to try someone's own work then spend a week trying to get it in my stuff.

Thanks Again.-Jeff

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #11 on: December 23, 2007, 02:55:06 AM »
Try this CSS.... that will get you started...

Code: [Select]
        body { font-family: verdana, san-serif; background-color: #FFFFFF; color: #000000;}
        a { font-size: 80%; text-decoration: none; color: #000000; font-weight: bold;
            padding-right: 340px; }
        a:visit { text-decoration: none; color: #000000; font-weight: bold;  }
        a:hover { text-decoration: underline; color: #000000; font-weight: bold;  }
        h1 { color: #000000; font-size: 120%; background-color: #639532; width: 60%;
            padding: 2px; border: 1px solid #000000;
            border-right: 3px solid #000000; border-bottom: 3px solid #000000; }
        h2 { font-size: 110%; }
        h3 { color: #000000; font-size: 100%; background-color: #639532; width: 30%;
            padding: 2px; border: 1px solid #000000;
            border-right: 3px solid #000000; border-bottom: 3px solid #000000;}
        .tbl { width: 65%; border: 1px solid #000000; border-collapse: collapse;
            border-right: 4px solid #000000; border-bottom: 4px solid #000000; }
        .left  { color: #000000; padding-left: 5px; font-family: verdana; width: 250px;
            border: 1px solid black; background-color: #D1F7AD;}
        .right { color: #000000; padding-left: 5px; font-family: "courier new", monospace;
            font-size: 90%; border: 1px solid black; background-color: #D1F7AD;}
        .rtbl { width: 25%; border: 1px solid #4A2409; border-collapse: collapse;
            border-right: 4px solid #000000; border-bottom: 4px solid #000000; }           
        .rain { text-align: center; color: #000000; padding-left: 5px;
            font-family: verdana; width: 250px;
            border: 1px solid black; background-color: #D1F7AD;}

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jhobby

  • Posts: 76
  • Silver Cliff, Colorado, USA
    • Silver Cliff, Colorado Weather
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #12 on: December 23, 2007, 02:59:58 AM »
Kevivn, Thank You Very Much, I am on it.
-Jeff

Offline BfdWx

  • Posts: 1,511
  • Branford Connecticut
    • Branford Weather
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #13 on: December 23, 2007, 03:07:35 AM »
Wow, go away for a few hours and Kevin adds all kinds of new scripts! :lol: Thanks for the new toys Kevin, Merry Christmas! Got it working in no time, now for the right place to add it....hmmmm. Looks like this will need a form type page to pick the month!

Jack

Offline jwwd

  • Posts: 3,545
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #14 on: December 23, 2007, 05:48:13 AM »
Henrik,

This gets closer...

http://www.tnetweather.com/scripts/wdavgext/test2.php

http://www.tnetweather.com/scripts/wdavgext/test2.txt


Hi Kevin

Thanks - its looking much better - i tried myself to change some of the words to Danish - but got it all messed up.

There is missing some lines from the December2007.htm - see attached pic where I have marked the missing with red, and the rain totals in the bottom.

www.buskelundtoften.dk/vejret/sample.php

Thanks for anohter great script.

Best regards,

Henrik
« Last Edit: December 23, 2007, 05:50:35 AM by jwwd »

 

cumulus