Author Topic: USA Extremes  (Read 19184 times)

0 Members and 1 Guest are viewing this topic.

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
USA Extremes
« on: September 20, 2012, 02:31:44 AM »
Is anyone else having problems with the USA Extremes script not working?




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline William Grimsley

  • Forecaster
  • *****
  • Posts: 1103
    • Newton Poppleford Weather
Re: USA Extremes
« Reply #1 on: September 20, 2012, 02:34:43 AM »
Hi hayskswx,

If that is "wxworldextremes.php" then No. Not having problems with the U.S.A or any other scripts.

Will
http://www.newton-poppleford-weather.co.uk
Davis Vantage Vue - Cumulus v1.9.4 (1084)
Weather Underground: IDEVONEX12
Met Office WOW: 717144
PWS Weather: ENG128597

Offline Dr Obbins

  • Forecaster
  • *****
  • Posts: 1152
Re: USA Extremes
« Reply #2 on: September 20, 2012, 06:39:35 AM »
Is anyone else having problems with the USA Extremes script not working?
Currently - Yes.

Offline n7xrd

  • Forecaster
  • *****
  • Posts: 366
    • Kamiah Weather
Re: USA Extremes
« Reply #3 on: September 20, 2012, 08:31:34 AM »
Yes mine is blank also!

Offline jgillett

  • Forecaster
  • *****
  • Posts: 1187
  • Boltek, Win7 Pro, ToA
    • TiggrWeather Phoenix
Re: USA Extremes
« Reply #4 on: September 20, 2012, 10:47:46 AM »
Same here - sidebar displays N/A for the three items, but wxworldextremes appears OK.
John
W7JKG

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: USA Extremes
« Reply #5 on: September 20, 2012, 10:52:22 AM »
Thanks. Mine says N/A as well.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline William Grimsley

  • Forecaster
  • *****
  • Posts: 1103
    • Newton Poppleford Weather
Re: USA Extremes
« Reply #6 on: September 20, 2012, 10:53:42 AM »
Ah, so you are using a different script to mine. Well, wxworldextremes.php is definitely working.

Will
http://www.newton-poppleford-weather.co.uk
Davis Vantage Vue - Cumulus v1.9.4 (1084)
Weather Underground: IDEVONEX12
Met Office WOW: 717144
PWS Weather: ENG128597

Offline Bunty

  • Forecaster
  • *****
  • Posts: 2432
  • Stillwater, home of Oklahoma State University
    • Welcome to Stillwater Weather
Re: USA Extremes
« Reply #7 on: September 20, 2012, 12:43:24 PM »
Thanks. Mine says N/A as well.

likewise, here.

Also the 2nd home page using modified AltDashboard 6.95 at http://stillwaterweather.com/2ndhome.php

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: USA Extremes
« Reply #8 on: September 20, 2012, 01:25:40 PM »
Odd, that. :shock:  My sidebar is reporting the same extremes as World Extremes.  Go figure.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline William Grimsley

  • Forecaster
  • *****
  • Posts: 1103
    • Newton Poppleford Weather
Re: USA Extremes
« Reply #9 on: September 20, 2012, 01:26:49 PM »
Odd, that. :shock:  My sidebar is reporting the same extremes as World Extremes.  Go figure.

Hmmm, this seems very strange. Hope it fixes soon Yankies!

Will
http://www.newton-poppleford-weather.co.uk
Davis Vantage Vue - Cumulus v1.9.4 (1084)
Weather Underground: IDEVONEX12
Met Office WOW: 717144
PWS Weather: ENG128597

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: USA Extremes
« Reply #10 on: September 20, 2012, 03:45:08 PM »
The URL has changed. Ive been messing with the new one and got the N/A part removed, now just working on getting the data to display.

I think im getting close on it, if I do figure it out, ill pass along the changes.
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: USA Extremes
« Reply #11 on: September 20, 2012, 03:47:20 PM »
The URL has changed. Ive been messing with the new one and got the N/A part removed, now just working on getting the data to display.

I think im getting close on it, if I do figure it out, ill pass along the changes.


Awesome Thanks!




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: USA Extremes
« Reply #12 on: September 20, 2012, 09:19:14 PM »
I got stuck on part of the code, so I've asked Ken to help me. When its been fixed I'll post the new script for this.
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Re: USA Extremes
« Reply #13 on: September 21, 2012, 09:01:34 AM »
Accuweather has embeeded this information as part of an ASP page that parses an XML file.

Done!  http://somdweather.com/usaextremes.php

Here is the snippet of PHP5 code to do this:

<?php
    $myextremes = simplexml_load_file('http://www.accuweather.com/adc2004/pub/includes/headlines/extremes.xml');
    $usahigh =  $myextremes->maxTemp->tempF . " F <br/>" . $myextremes->maxTemp->city . ", " . $myextremes->maxTemp->state;


    $usalow =  $myextremes->minTemp->tempF . " F <br/>". $myextremes->minTemp->city . ", " . $myextremes->minTemp->state;


    $usaprecip =  $myextremes->maxPrec->precIN . " in<br/>". $myextremes->maxPrec->city . ", " . $myextremes->maxPrec->state;


?>

Hope this helps!



Jim

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: USA Extremes
« Reply #14 on: September 21, 2012, 10:32:46 AM »
Jim do I replace my usaextremes.php file with the script that you posted?




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Re: USA Extremes
« Reply #15 on: September 21, 2012, 10:38:27 AM »
Ryan,
  The little snippet of code that I provided is the heart of the script. The variables $usahigh,$usalow, and $usaprecip actually hold the data. You can use these variables and format them to what you need. I suspect Ken or someone else will roll something similar into the pre-existing usaextremes.php file or develop a new one.

Jim

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: USA Extremes
« Reply #16 on: September 21, 2012, 10:39:47 AM »
Ok Thanks Jim.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline William Grimsley

  • Forecaster
  • *****
  • Posts: 1103
    • Newton Poppleford Weather
Re: USA Extremes
« Reply #17 on: September 21, 2012, 10:53:30 AM »
Glad you have got your USA Extremes sorted! Might have turned into a tragedy!

Will
http://www.newton-poppleford-weather.co.uk
Davis Vantage Vue - Cumulus v1.9.4 (1084)
Weather Underground: IDEVONEX12
Met Office WOW: 717144
PWS Weather: ENG128597

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: USA Extremes
« Reply #18 on: September 21, 2012, 06:30:02 PM »
I got stuck on part of the code, so I've asked Ken to help me. When its been fixed I'll post the new script for this.

I suspect Ken or someone else will roll something similar into the pre-existing usaextremes.php file or develop a new one.

Jim

Ken is working on getting this data from WU since Accuweather is pretty strict on sharing there info.
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: USA Extremes
« Reply #19 on: September 21, 2012, 10:55:32 PM »
At Mark's request, I've redone the usaextremes.php script from relayweather to use WeatherUnderground as the source for the data.

Here's the code for usaextremes.php
Code: [Select]
<?php
############################################################################
#
#   Project:    USA Extremes
#   Module:     usaextremes.php
#   Purpose:    Provides USA Extremes for Web page display
#   Authors:    Michael (michael@relayweather.com)
#               Ken True (webmaster@saratoga-weather.org) V2.01
############################################################################
# Usage:  Place the following on your webpage
# CHMOD 666 for cacheFile2.php
# include_once('usaextremes.php');
#
# Then call the following tags within the page where you would like them displayed:
# $usahigh
# $usalow
# $usaprecip
#
#  Note: allow_url_fopen = on 
#    in your php.ini is required to run this script.
############################################################################
// version
// Version 2.00 - 14-Sep-2010 - initial release
// Version 2.01 - 21-Sep-2012 - adapted for WeatherUnderground use - K. True
$usaextremesverion "2.01";
echo 
"<!-- USA Extremes Script Version $usaextremesverion. -->\n";
/////////////////////////////////////////////////////////////////////////////
//SETTINGS START HERE////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Site to Parse
$url2 "http://www.wunderground.com/climate/extremes.asp";
// Set the time zone
$ourTZ 'America/Los_Angeles';
// Name of cache file  --  This file must be set to CHMOD-666
$cacheFile2 "usaextremesCache.php";  
// Age of cache file before re-fetch caching time, in seconds (3600 = 1 hour)
$cache_life '3600'
/////////////////////////////////////////////////////////////////////////////
//END SETTINGS///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////// 
if (file_exists($cacheFile2)) {
    
$filemtime filemtime($cacheFile2);
    
$filesize filesize($cacheFile2);
    if (
== $filesize){
        
$filemtime 0;
    }
} else {
    
$filemtime 0;
}   
//   open the cache file and write the new data and then close the file.
$forceRefresh = (isset($_REQUEST['force']))?true:false;
$current_time time();
$cache_age $current_time $filemtime;
if (
$forceRefresh or $cache_age >= $cache_life){
   
$html2 implode(' 'file($url2)); 
   
$fp2 fopen($cacheFile2'w');
   
fwrite($fp2$html2);
   
fclose($fp2);
   echo 
"<!-- The cache life HAS expired and fresh data re-wrote the cache file -->\n";
} else {
   echo 
"<!-- The cache life HAS NOT expired and fresh data was not written to the cache file -->\n";
// Open the cache file, read it, then close it   
    
$handle2 fopen($cacheFile2"r");
    
$filesize filesize($cacheFile2);
    
$html2 fread($handle2$filesize);
    
fclose($handle2);
}


//Finds USA High
preg_match_all('|<div id="highTemp"[^>]*>(.*)</div>|Uis'$html2$matches);
//  print "<pre>\n".print_r($matches,true)."</pre>\n";

if(isset($matches[1][0])) { 
  
$hightable $matches[1][0]; 
  
preg_match_all('|<td>(.*)</td>|Uis',$hightable,$matches);
  
//  print "<pre>\n".print_r($matches,true)."</pre>\n";

  
$usahigh trim(preg_replace("|\n|is",'',strip_tags($matches[1][2]).'<br/>'.strip_tags($matches[1][0])));  
  print 
"<!-- usahigh='$usahigh' -->\n";
} else {
$usahigh 'N/A';
}

//Finds USA Low
preg_match_all('|<div id="lowTemp"[^>]*>(.*)</div>|Uis'$html2$matches);
//  print "<pre>\n".print_r($matches,true)."</pre>\n";

if(isset($matches[1][0])) { 
  
$lowtable $matches[1][0]; 
  
preg_match_all('|<td>(.*)</td>|Uis',$lowtable,$matches);
  
//  print "<pre>\n".print_r($matches,true)."</pre>\n";

  
$usalow trim(preg_replace("|\n|is",'',strip_tags($matches[1][2]).'<br/>'.strip_tags($matches[1][0])));  
  print 
"<!-- usalow='$usalow'-->\n";
} else {
$usalow 'N/A';
}

//Finds USA High Precip
preg_match_all('|<div id="precip"[^>]*>(.*)</div>|Uis'$html2$matches);
//  print "<pre>\n".print_r($matches,true)."</pre>\n";

if(isset($matches[1][0])) { 
  
$raintable $matches[1][0]; 
  
preg_match_all('|<td>(.*)</td>|Uis',$raintable,$matches);
  
//  print "<pre>\n".print_r($matches,true)."</pre>\n";

  
$usaprecip trim(preg_replace("|\n|is",'',strip_tags($matches[1][2]).'<br/>'.strip_tags($matches[1][0])));  
  print 
"<!-- usaprecip='$usaprecip' -->\n";
} else {
$usaprecip 'N/A';
}
print 
'<!-- $filemtime = '.$filemtime.' $cache_age = '.$cache_age.' seconds.' " -->\n";
print 
"<!-- Cache refresh rate = $cache_life seconds.  Cache age = $cache_age seconds. -->\n";
?>

After installing, you may need to run it with ?force=1 to clear the cache and reload the page from Wunderground.

Let me know how it works for you...

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

Offline n7xrd

  • Forecaster
  • *****
  • Posts: 366
    • Kamiah Weather
Re: USA Extremes
« Reply #20 on: September 21, 2012, 11:05:31 PM »
 :grin:  Thanks Ken seems to working great!!!!

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: USA Extremes
« Reply #21 on: September 21, 2012, 11:12:36 PM »
Works great... Thanks for your time in fixing this script Ken.
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: USA Extremes
« Reply #22 on: September 21, 2012, 11:38:38 PM »
Thanks as always Ken.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline jgillett

  • Forecaster
  • *****
  • Posts: 1187
  • Boltek, Win7 Pro, ToA
    • TiggrWeather Phoenix
Re: USA Extremes
« Reply #23 on: September 22, 2012, 12:19:12 AM »
Works great, Ken - as always!

Thank you :!:
John
W7JKG

Offline Maumelle Weather

  • Forecaster
  • *****
  • Posts: 1825
    • Maumelle Weather
Re: USA Extremes
« Reply #24 on: September 22, 2012, 07:27:43 AM »
Hi Jim,

Thanks for the code snippet!!!

John
GR2AE, GR3, Cumulus

 

anything