Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HtmlDoc.GetTable error?
#10
This is my function to display the weather in a readable format.
I abbreviate "Precipitation" with "P" and "Humidity" with "H", feel free to change it to whatever you like. :-)
Beside you can change the location to reflect your own city from this website.
This function could apply to the 5-Day forecast also.
Note: for better viewing, change the display font to mono font like "Courier New".

Macro 10-Day Weather Forecast
Code:
Copy      Help
out
run "http://www.weather.com/weather/tenday/48183"
int w=wait(25 WV win("Day Weather Forecast - The Weather Channel | Weather.com - Mozilla Firefox" "MozillaWindowClass"))
Acc a.FindFF(w "DIV" "" "data-module-id=forecast_24hour" 0x1004 3)
ARRAY(Acc) k; int i
a.GetChildObjects(k MakeInt(4 5))
ARRAY(str) b
str weather
for i 0 k.len
,b[]=k[i].Name
weather=b
showWeather weather

Function showWeather
Code:
Copy      Help
function $s
str line concat
int found firstTime=1
foreach line s
,if(line="TODAY")
,,out "TODAY:"
,,line="   "
,if(line=" " or line.len=0 or line="[]" or line="--") continue
,if(line="")
,,concat.findreplace("F   Low", "Low")
,,concat.findreplace(" F ", " ")
,,concat.findreplace(" ° " "°F, ")
,,out concat
,,concat.all
,else
,,line.findreplace("::'Chance of Precipitation'" "P:")
,,line.findreplace("mph" "mph, H:")
,,if(find(line "Low")>-1)
,,,if firstTime
,,,,line=_s.from("  " line)
,,,,firstTime=0
,,if (find(line "Jan")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "Feb")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "Mar")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "Apr")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "May")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "Jun")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "Jul")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "Aug")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "Sep")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "Oct")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "Nov")>-1)
,,,if(line.len=5) line+=" "
,,else if (find(line "Dec")>-1)
,,,if(line.len=5) line+=" "
,,line.findreplace("::'Low Temperature'" "Low:")
,,line.findreplace(" | pfTranslate: weather_terms_context" "")
,,line.findreplace("Sun" "Sun," 2)
,,line.findreplace("Cloudy" "Cloudy,")
,,line.findreplace("Sunny" "Sunny,")
,,line.findreplace("Rainy" "Rainy,")
,,line.findreplace("Windy" "Windy,")
,,concat += _s.from(line " ")


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)