Author |
|
kemaa Newbie
Joined: October 17 2007
Online Status: Offline Posts: 18
|
Posted: November 06 2007 at 17:33 | IP Logged
|
|
|
I am trying to update the GETWEATHER macro from Tony by adding a few other results. I copied an expanded macro from someone else (sorry, I don't remember who) and tried to play with some of the parts of it. Ultimately, I'm trying to take the forecast and play it back using TTS. I have been trying to grab various pieces of the page back using both regexsnap and regexdiff. I don't get any return data. Based on what I *think* I understand I should return the text "<td align="left">
<b>Tonight" with:
ph_regexsnap('<b>Forecast as of~255</td></tr>\(.+\)</b><br/>',"[LOCAL1]",1,0).
This instead returns nothing. I am using the call after returning the temperature and speaking it via TTS.
I was also trying it with the same results through:
ph_regexdiff('<b>Forecast as of~255</b><br/>','</b><br/>',"[LOCAL1]",1,0)
|
Back to Top |
|
|
jbbtex Senior Member
Joined: February 15 2007 Location: United States
Online Status: Offline Posts: 181
|
Posted: November 06 2007 at 18:26 | IP Logged
|
|
|
From PH Help regarding both regexsnap & regexdif:
"This function will also not perform a regular expression search that spans multiple lines. If the data to search contains carraige returns or line feeds, the entire matching search data for the regular expression must exist within a single line. If your regular expression must span across a line, then add 2 to the flags to have CR's and LF's temporarily converted. CR will be converted to ASCII 128 and LF will be converted to ASCII 129. If you convert CF/LF then you can include them in your search with PowerHome escape characters ~128 and ~129 respectively."
I use the National Weather Service text only forecast.
http://forecast.weather.gov/MapClick.php?CityName=Lorena&sta te=TX&site=FWD&textField1=31.3823&textField2=-97.2127&e=0&Te xtType=1
And this function:
ph_regexdiff(": </b>",".<br>~129<br>","[LOCAL1]",1250,3)
which consistently returns the current forecast. (That is until the weather service decides to change their format.)
I need to add that I use the weather underground page and the macro that TonyNo shared with the world for current weather conditions. (Thanks, Tony)
Edited by jbbtex - November 06 2007 at 18:46
__________________ Brady
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity." - Gen. George S. Patton
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: November 06 2007 at 19:40 | IP Logged
|
|
|
Here is the line that pulls my forecast reliably...
ph_regexdiff('<b>Forecast as of~255 /><br />','<br /><br />',"[LOCAL1]",1,0)
LOCAL1 contains the grabbed WML page. The result of this is put into LOCAL4 and then these...
ph_replaceall( "[LOCAL4]", "~n", "" )
ph_replaceall( "[LOCAL4]", "~r", "" )
...strip out the line feeds and carriage returns.
Here is the area in the WML code that I am working with...
<b>Forecast as of 3:40 PM CST on November 6, 2007 </b> </center><br />
</td>
</tr><tr>
<td align="left">
<b>Tonight</b><br />
<img src="http://icons.wunderground.com/graphics/fun_map/nt_sunny .gif" width="42" height="42" border="1" alt="" /><br />
Mostly clear. Cold. Lows in the mid 20s. Northwest winds 10 to 15 mph until early morning becoming light and variable during the predawn hours. <br /><br />
<b>Wednesday</b><br />
It seems to span multiple lines, but it always works for me.
|
Back to Top |
|
|
|
|