[Printable]
Share

Display Inshore forecast from BOM for digital signage or website

Posted: Wed 10th April 2019 in Scripts
Position: 12° 27.6' S, 130° 48.1' E

the Following code will go grab the xml for the Darwin Harbour inshore forecast from BOM and save it to disk as a htm and txt file.

The idea is run it once as a cron job - then just call the txt or htm file to display it for hte rest of the day

getElementsByTagName('forecast') as $e ) {
  $e = $e->parentNode; // this should be the  element
  foreach( $e->getElementsByTagName('forecast-period') as $l ) {
  if($l->getAttribute('index')=='0') {
								$date = date( "l jS F ", strtotime($l->getAttribute('start-time-local')));
								$curTxt= "Forcast for Darwin Harbour for $date \n \n";
								$curHtm= "

Forcast for Darwin Harbour for $date

\n\n"; foreach( $l->getElementsByTagName('text') as $t ) { // echo 'name '.$l->getAttribute('type')."\n"; // echo 'data '.$l->nodeValue."\n"; $type=preg_replace('/[0-9]+/', '',strtoupper(preg_replace("/_/", " ", $t->getAttribute('type')))); $typeHtm=preg_replace('/[0-9]+/', '',ucfirst(preg_replace("/_/", " ", $t->getAttribute('type')))); $txt = $t->nodeValue; $curTxt=$curTxt.$type.': '.$txt."\n\n"; $curHtm=$curHtm."\n"; } } } } //Dispaly as text echo $curTxt; file_put_contents('../../imagecache/forecast.txt', $curTxt); //save file for rest of the day. //separator echo "##############################################################################
\n"; //display as html $curHtm=$curHtm."
$typeHtm $txt
"; echo $curHtm; file_put_contents('../../imagecache/forecast.htm', $curHtm); //save file for the resrt of hte day. ?>
[Printable]
Share

Display Inshore forecast from BOM for digital signage or website

Posted: Wed 10th April 2019 in Scripts
Position: 12° 27.6' S, 130° 48.1' E

Display Inshore forecast from BOM for digital signage or website

the Following code will go grab the xml for the Darwin Harbour inshore forecast from BOM and save it to disk as a htm and txt file.

The idea is run it once as a cron job - then just call the txt or htm file to display it for hte rest of the day

getElementsByTagName('forecast') as $e ) {
  $e = $e->parentNode; // this should be the  element
  foreach( $e->getElementsByTagName('forecast-period') as $l ) {
  if($l->getAttribute('index')=='0') {
								$date = date( "l jS F ", strtotime($l->getAttribute('start-time-local')));
								$curTxt= "Forcast for Darwin Harbour for $date \n \n";
								$curHtm= "

Forcast for Darwin Harbour for $date

\n\n"; foreach( $l->getElementsByTagName('text') as $t ) { // echo 'name '.$l->getAttribute('type')."\n"; // echo 'data '.$l->nodeValue."\n"; $type=preg_replace('/[0-9]+/', '',strtoupper(preg_replace("/_/", " ", $t->getAttribute('type')))); $typeHtm=preg_replace('/[0-9]+/', '',ucfirst(preg_replace("/_/", " ", $t->getAttribute('type')))); $txt = $t->nodeValue; $curTxt=$curTxt.$type.': '.$txt."\n\n"; $curHtm=$curHtm."\n"; } } } } //Dispaly as text echo $curTxt; file_put_contents('../../imagecache/forecast.txt', $curTxt); //save file for rest of the day. //separator echo "##############################################################################
\n"; //display as html $curHtm=$curHtm."
$typeHtm $txt
"; echo $curHtm; file_put_contents('../../imagecache/forecast.htm', $curHtm); //save file for the resrt of hte day. ?>