Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: WeatherUnderground - GetWeather Macro Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: January 24 2003 at 21:09 | IP Logged Quote dhoward

Tony,

You da man!!

Im in Florida and it is pretty darn cold here.  Supposed to get down to 23 tonight.  Im going to have to move further south .

Dave.

 

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: January 25 2003 at 09:27 | IP Logged Quote TonyNo

Dave,

I remember being a kid in Florida (back in '75), it getting "cold", and walking around with socks on my hands for gloves! It wasn't even cold (it was only about 40)!

Tony

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 04 2003 at 08:40 | IP Logged Quote TonyNo

They've changed the page again!

Looking through the HTML...

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 05 2003 at 07:56 | IP Logged Quote TonyNo

I've updated my macro, but, it does not work! Duplicating the macro in VB does, though.

Maybe this is another variable problem in PH?

The only change is...

"<td>Temperature</td>" was changed to...

"<td width="100%">Temperature</td>"

...so, my search string is now ">Temperature</td>"

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 05 2003 at 12:56 | IP Logged Quote dhoward

Tony,

Great detective work!!  You hit the nail on the head also.  The reason it doesnt work with the macro is that same problem with the pos function flaking out with start values in the 34000 range.  You definately need your fix, but also a small change on line 10.  The corrected line 10 is:

mid(ph_geturl("http://www.weatherunderground.com/cgi-bin/findweather/getForecast?query=32707"),20000,30000)

You can see that I changed the left to a mid and started at 20000 and grabbed 30000 characters.  This grabs the same set of data as before and just throws away the first 20000 characters of junk.  This will reset all the positions down 20000 and puts us in the 14000 range as the start position which works just fine now.  

For anyone else interested, Im posting below the new GetWeather macro with Tony's fix as well as my fix for the POS problem:

insert into macroheader values ('GET WEATHER','GET WEATHER',4,4,252,96,0,0,0,12632256,0,1,1,'MACROS');
insert into macrodetail values ('GET WEATHER',1,15,'[LOCAL1]',NULL,'mid(ph_geturl("http://www.weatherunderground.com/cgi-bin/findweather/getForecast?query=32707"),20000,30000)');
insert into macrodetail values ('GET WEATHER',2,15,'[LOCAL2]',NULL,'pos(ph_getvar_s(1,1),"<b>",pos(ph_getvar_s(1,1),">Temperature</td>")) + 3');
insert into macrodetail values ('GET WEATHER',3,15,'[LOCAL3]',NULL,'mid(ph_getvar_s(1,1),ph_getvar_n(1,2),3)');
insert into macrodetail values ('GET WEATHER',4,15,'[LOCAL4]',NULL,'"The temperature is " + if(isnumber(ph_getvar_s(1,3)),ph_getvar_s(1,3),left(ph_getvar_s(1,3),2)) + " degrees. "');
insert into macrodetail values ('GET WEATHER',5,15,'[LOCAL2]',NULL,'pos(ph_getvar_s(1,1),"<b>",pos(ph_getvar_s(1,1),"<td>Humidity</td>",ph_getvar_n(1,2))) + 3');
insert into macrodetail values ('GET WEATHER',6,15,'[LOCAL3]',NULL,'mid(ph_getvar_s(1,1),ph_getvar_n(1,2),3)');
insert into macrodetail values ('GET WEATHER',7,15,'[LOCAL4]',NULL,'ph_getvar_s(1,4) + "The humidity is " + if(isnumber(ph_getvar_s(1,3)),ph_getvar_s(1,3),left(ph_getvar_s(1,3),2)) + " percent. "');
insert into macrodetail values ('GET WEATHER',8,15,'[LOCAL2]',NULL,'pos(ph_getvar_s(1,1),"<b>Forecast for ")');
insert into macrodetail values ('GET WEATHER',9,15,'[LOCAL1]',NULL,'mid(ph_getvar_s(1,1),ph_getvar_n(1,2))');
insert into macrodetail values ('GET WEATHER',10,15,'[LOCAL2]',NULL,'pos(ph_getvar_s(1,1),"<td align=left><b>") + 18');
insert into macrodetail values ('GET WEATHER',11,15,'[LOCAL3]',NULL,'pos(ph_getvar_s(1,1),"</b>",ph_getvar_n(1,2))');
insert into macrodetail values ('GET WEATHER',12,15,'[LOCAL4]',NULL,'ph_getvar_s(1,4) + "The forecast for " + mid(ph_getvar_s(1,1),ph_getvar_n(1,2),ph_getvar_n(1,3) - ph_getvar_n(1,2)) + " is "');
insert into macrodetail values ('GET WEATHER',13,15,'[LOCAL2]',NULL,'ph_getvar_n(1,3) + 9');
insert into macrodetail values ('GET WEATHER',14,15,'[LOCAL3]',NULL,'pos(ph_getvar_s(1,1),"</td>",ph_getvar_n(1,2))');
insert into macrodetail values ('GET WEATHER',15,15,'[LOCAL4]',NULL,'ph_getvar_s(1,4) + mid(ph_getvar_s(1,1),ph_getvar_n(1,2),ph_getvar_n(1,3) - ph_getvar_n(1,2))');
insert into macrodetail values ('GET WEATHER',16,15,'[LOCAL2]',NULL,'pos(ph_getvar_s(1,4),"winds")');
insert into macrodetail values ('GET WEATHER',17,16,'',NULL,'if(ph_getvar_n(1,2) = 0,3,1)');
insert into macrodetail values ('GET WEATHER',18,15,'[LOCAL4]',NULL,'replace(ph_getvar_s(1,4),ph_getvar_n(1,2),5,"wins")');
insert into macrodetail values ('GET WEATHER',19,16,'',NULL,'- 3');
insert into macrodetail values ('GET WEATHER',20,9,'',NULL,'ph_getvar_s(1,4)');

Great job Tony!

Dave.

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: August 11 2003 at 21:52 | IP Logged Quote TonyNo

Yet again, the code bloats!

Change:

mid( ph_geturl( "www.wunderground.com/cgi-bin/findweather/getForecast?query=YOURZIP"), 20000, 30000)

To:

mid( ph_geturl( "www.wunderground.com/cgi-bin/findweather/getForecast?query=YOURZIP"), 30000, 30000)

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: August 12 2003 at 07:08 | IP Logged Quote dhoward

It just keeps getting bigger and bigger and bigger....

 

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: July 21 2004 at 08:02 | IP Logged Quote TonyNo

I have a solution to this code bloat! I'm going to make this tap into a WAP weather page! Those are nice and small!

More to come...
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: July 21 2004 at 11:31 | IP Logged Quote dhoward

Tony,

Great minds think alike!!  Ive used their WAP page to get the temperature for my HVAC routines for about a month now.  Much smaller and easier to work with.

It would be great if you came up with a macro that you could post here.  Maybe something generic that takes the zipcode as a parameter so people could just call it with ph_macroparm such as: ph_macroparm("GET WEATHER",32707,0,0,0,0)

Also, Ive come up with a solution for the problem with this line:

insert into macrodetail values ('GET WEATHER',1,15,'[LOCAL1]',NULL,'mid(ph_geturl("http://www.weatherunderground.com/cgi-bin/findweather/getForecast?query=32707"),20000,30000)');

The problem has been that the "pos" function fails when dealing with positions greater than approx 32000 so we've had to try to snapshot the area were interested in with the "mid" function.  The problem is, weatherunderground keeps changing their page and this "interesting area" keeps moving around.  The solution is to use the "posw" function.  This function works just like the "pos" function but has no problems working with positions greater than 32000.  Using this function, we don't need to worry with the "mid" function.

Good luck,

Dave.

 

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: July 22 2004 at 07:15 | IP Logged Quote TonyNo

I'll work on that.

posw, huh? Must be in the new version; can't find it in my docs. Sounds good, though!

Tony
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: July 22 2004 at 09:44 | IP Logged Quote dhoward

Its in the current version...just slipped through the documentation .

Dave.

 

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: July 22 2004 at 13:14 | IP Logged Quote onhiatus

Not exactly on topic - I don't use any weather pages at home, but I do scrape data for a mobile phone applet that I've written. I find the NOAA weather pages the easiest to work with - you can get them in plain text - nice small, predictable formatting. I haven't seen a change in the format in the year I've been using them.

If weather underground changes again, you might consider one of these.

For long forcasts I use NOAA Forcasts (Seattle):
http://www.wrh.noaa.gov/cgi-bin/Seattle/afd?SEASFTSEW

For detailed forcasts, NOAA zone (also Seattle / NWS):
http://www.wrh.noaa.gov/cgi-bin/Seattle/afd?SEAZFPSEW

For current conditions I use METAR data - this is used by airports (Again, Seattle - Boeing Field):
Raw: http://www.wrh.noaa.gov/cgi-bin/wrhq/GetMetar.cgi?SEA+Metar
Translated: http://www.wrh.noaa.gov/cgi-bin/wrhq/GetMetar.cgi?SEA+Public

Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: July 26 2004 at 19:20 | IP Logged Quote TonyNo

Here is the macro for getting weather info from a WAP site. It is set up, as Dave suggested, to allow passing of a ZIP code into the macro. There are also comments to help explain things a bit.

Let me know if there are questions or suggestions.

insert into macroheader values ('WEATHER','WEATHER',4,4,252,96,0,0,0,12632256,0,0,1,'',10);
insert into macrodetail values ('WEATHER',1,37,'',NULL,'Call with ZIP code in [LOCAL1]',0);
insert into macrodetail values ('WEATHER',2,37,'',NULL,'Pull weather into [LOCAL1]',0);
insert into macrodetail values ('WEATHER',3,15,'[LOCAL1]',NULL,'ph_geturl( "cingular.weather.com/myweather/currentconditions/" + [LOCAL1] )',0);
insert into macrodetail values ('WEATHER',4,24,'No TTS',1,'"[LOCAL1]"',0);
insert into macrodetail values ('WEATHER',5,37,'',NULL,'Find "temp:" and put position after',0);
insert into macrodetail values ('WEATHER',6,15,'[LOCAL2]',NULL,'pos( "[LOCAL1]", "temp: ") + 6',0);
insert into macrodetail values ('WEATHER',7,37,'',NULL,'Put the temperature (3 characters) into [LOCAL2]',0);
insert into macrodetail values ('WEATHER',8,15,'[LOCAL2]',NULL,'mid( "[LOCAL1]", [LOCAL2], 3)',0);
insert into macrodetail values ('WEATHER',9,37,'',NULL,'Say the temp',0);
insert into macrodetail values ('WEATHER',10,9,'',NULL,'"The temperature is " + if( isnumber( "[LOCAL2]"), "[LOCAL2]", left( "[LOCAL2]", 2)) + " degrees, "',0);
insert into macrodetail values ('WEATHER',11,37,'',NULL,'Find "Humidity:" and put position after',0);
insert into macrodetail values ('WEATHER',12,15,'[LOCAL2]',NULL,'pos( "[LOCAL1]", "Humidity:") + 10',0);
insert into macrodetail values ('WEATHER',13,37,'',NULL,'Put the humidity (3 characters) into [LOCAL3]',0);
insert into macrodetail values ('WEATHER',14,15,'[LOCAL3]',NULL,'mid( "[LOCAL1]", [LOCAL2], 3 )',0);
insert into macrodetail values ('WEATHER',15,37,'',NULL,'Say the humidity',0);
insert into macrodetail values ('WEATHER',16,9,'',NULL,'"and the humidity is " + "[LOCAL3]" + " percent. "',0);
insert into macrodetail values ('WEATHER',17,37,'',NULL,'Find "Barometer:" and put position after',0);
insert into macrodetail values ('WEATHER',18,15,'[LOCAL4]',NULL,'pos( "[LOCAL1]", "Barometer: ") + 11',0);
insert into macrodetail values ('WEATHER',19,37,'',NULL,'Find "Wind" (comes right after thepressure)',0);
insert into macrodetail values ('WEATHER',20,15,'[LOCAL5]',NULL,'pos( "[LOCAL1]", "Wind: ") - 21',0);
insert into macrodetail values ('WEATHER',21,37,'',NULL,'Remove  ',0);
insert into macrodetail values ('WEATHER',22,15,'[LOCAL4]',NULL,'ph_replaceall ( mid( "[LOCAL1]", [LOCAL4], [LOCAL5] - [LOCAL4] ), " ", "" )',0);
insert into macrodetail values ('WEATHER',23,37,'',NULL,'Replace decimal point with the word "point"',0);
insert into macrodetail values ('WEATHER',24,15,'[LOCAL4]',NULL,'ph_replaceall ( "[LOCAL4]", ".", " point " )',0);
insert into macrodetail values ('WEATHER',25,37,'',NULL,'Say pressure and trend',0);
insert into macrodetail values ('WEATHER',26,9,'',NULL,'"The barometric pressure is " + "[LOCAL4]"',0);
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
npavkov
Groupie
Groupie


Joined: February 29 2004
Location: United States
Online Status: Offline
Posts: 91
Posted: August 05 2004 at 14:36 | IP Logged Quote npavkov

Tony, I am not able to get this last posted macro to work..... it says Timed out. I can not get to this url directly thru IE either. I just would like a macro to get current weather conditions in my area...... Help please....Nick
Back to Top View npavkov's Profile Search for other posts by npavkov
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: August 05 2004 at 23:07 | IP Logged Quote TonyNo

You are calling it as described, correct?

ph_macroparm("WEATHER",32707,0,0,0,0)

32707 would be replaced with your ZIP code.

IE will not load this page since it is WML. If you want to try it, do so here.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
npavkov
Groupie
Groupie


Joined: February 29 2004
Location: United States
Online Status: Offline
Posts: 91
Posted: August 06 2004 at 15:26 | IP Logged Quote npavkov

Tony... when I call the macro as stated above, it gives me error 'timeout connecting'. do I have to set up anything for powerhome to access the internet??? thanks nick.
Back to Top View npavkov's Profile Search for other posts by npavkov
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: August 06 2004 at 21:46 | IP Logged Quote TonyNo

Hmm. Do you have dial-up, or, broadband? If dial-up, you'll need to initiate an internet connection. If BB, it should just work. I did notice that I left a debugging Message Box line in there that can be removed.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
npavkov
Groupie
Groupie


Joined: February 29 2004
Location: United States
Online Status: Offline
Posts: 91
Posted: August 07 2004 at 22:30 | IP Logged Quote npavkov

Tony...I have broadband on a router (w/ cable modem). Do I have to change ANY PH settings to access the internet from PH.... The machine that PH runs on is a bit slow though, maybe he timeout is because of a shorter timeout period or long access time.... I am not sure what I got to do to make this internet access from PH work..... any suggestions????? thanks
Back to Top View npavkov's Profile Search for other posts by npavkov
 
npavkov
Groupie
Groupie


Joined: February 29 2004
Location: United States
Online Status: Offline
Posts: 91
Posted: August 07 2004 at 22:41 | IP Logged Quote npavkov

apparrentlyu Tony, the geturl webpage is timing out, I am able to get a return from google.com using geturl function..... is this the correct weather page url name????
Back to Top View npavkov's Profile Search for other posts by npavkov
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: August 08 2004 at 00:53 | IP Logged Quote dhoward

I just got around to loading up Tony's "WEATHER" macro and testing it. Works great! Nicely commented.

Nick, just as a test, try the following formula in the formula evaluator:

ph_geturl("cingular.weather.com/myweather/currentconditions/32707")

You can replace the "32707" with your zipcode. Assuming everything works correctly, the forumla should evaluate to the HTML of the web page and will start with "HTTP/1.1 200 OK...". The "200" means that the webpage was retrieved correctly. This is the first part that we have to get working. If this fails, your ISP may be having problems reaching Cingular. In that case, Ive whipped up another "GET WEATHER" macro that uses the mobile page URL of "weatherunderground". It doesn't have quite as much info as Tony's but does have the temp, humidity and current forecast. The code is posted below:

insert into macroheader values ('GET WEATHER','GET WEATHER',4,4,252,96,0,0,0,12632256,0,0,1,'',10);
insert into macrodetail values ('GET WEATHER',5,15,'[TEMP2]',NULL,'posw(ph_getvar_s(1,1),"</b>",[TEMP1])',0);
insert into macrodetail values ('GET WEATHER',7,37,'',NULL,'Find Humidity',0);
insert into macrodetail values ('GET WEATHER',9,15,'[TEMP1]',NULL,'posw(ph_getvar_s(1,1),"<b>",[TEMP1])',0);
insert into macrodetail values ('GET WEATHER',11,15,'[LOCAL3]',NULL,'"The humidity is " + mid(ph_getvar_s(1,1),[TEMP1] + 3,[TEMP2] - [TEMP1] - 3) + " percent."',0);
insert into macrodetail values ('GET WEATHER',13,15,'[TEMP1]',NULL,'posw(ph_getvar_s(1,1),"<b>Now</b>")',0);
insert into macrodetail values ('GET WEATHER',15,15,'[TEMP2]',NULL,'posw(ph_getvar_s(1,1),"</td>",[TEMP1])',0);
insert into macrodetail values ('GET WEATHER',17,24,'TTS',1,'"[LOCAL2] [LOCAL3] [LOCAL4]"',0);
insert into macrodetail values ('GET WEATHER',2,37,'',NULL,'Find Temperature',0);
insert into macrodetail values ('GET WEATHER',4,15,'[TEMP1]',NULL,'posw(ph_getvar_s(1,1),"<b>",[TEMP1])',0);
insert into macrodetail values ('GET WEATHER',6,15,'[LOCAL2]',NULL,'"The temperature is " + mid(ph_getvar_s(1,1),[TEMP1] + 3,[TEMP2] - [TEMP1] - 3) + " degrees."',0);
insert into macrodetail values ('GET WEATHER',8,15,'[TEMP1]',NULL,'posw(ph_getvar_s(1,1),"<td>Humidity</td>")',0);
insert into macrodetail values ('GET WEATHER',10,15,'[TEMP2]',NULL,'posw(ph_getvar_s(1,1),"%",[TEMP1])',0);
insert into macrodetail values ('GET WEATHER',12,37,'',NULL,'Get the current forecast',0);
insert into macrodetail values ('GET WEATHER',14,15,'[TEMP1]',NULL,'posw(ph_getvar_s(1,1),"~n",[TEMP1])',0);
insert into macrodetail values ('GET WEATHER',16,15,'[LOCAL4]',NULL,'"The current forecast is: " + mid(ph_getvar_s(1,1),[TEMP1] + 1,[TEMP2] - [TEMP1] - 1)',0);
insert into macrodetail values ('GET WEATHER',1,15,'[LOCAL1]',NULL,'ph_geturl("http://mobile.wunderground.com/cgi-bin/findweather/getForecast?brand=mobile&query=[LOCAL1]")',0);
insert into macrodetail values ('GET WEATHER',3,15,'[TEMP1]',NULL,'posw(ph_getvar_s(1,1),"<td>Temperature</td>")',0);

Good luck,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 

<< Prev Page of 5 Next >>
  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum