Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HtmlDoc.GetTable error?
#1
I've tried this example from the Help file:
Macro Macro26
Code:
Copy      Help
out
HtmlDoc d.InitFromWeb("http://www.w3schools.com/html/html_tables.asp")
ARRAY(str) a
d.GetTable(8 a)

int i
for i 0 a.len 2
,out "%s=%s" a[i] a[i+1]
,
But I've got this error message:
Error (RT) in <open ":7737: /91">Macro26: object not found (table). <help #IDP_ERR>?

What's wrong with it?
#2
Macro Macro2823
Code:
Copy      Help
out
HtmlDoc d.InitFromWeb("http://www.w3schools.com/html/html_tables.asp")
ARRAY(str) a
int t
for t 0 1000
,d.GetTable(t a)
,out F"<><Z 0xa080>table {t}</Z>"
,int i
,for i 0 a.len 2
,,out "%s=%s" a[i] a[i+1]
,,
#3
So you have to put it in a loop in order to get all of its elements.
Thanks it works now.
#4
Use loop when need all tables. Or to find table by its content, when table index is unknown.
#5
I've got it.
Thanks for clarification. Smile
#6
How about this website? I see it has table but the code could not find it.
Macro Macro26
Code:
Copy      Help
out
HtmlDoc d.InitFromWeb("http://www.weather.com/weather/tenday/48183")
ARRAY(str) a
int i j
for i 0 100
,out F"<><Z 0xa080>Table {i}</Z>"
,d.GetTable(i a); err
,for j 0 a.len 2
,,out "%s=%s" a[j] a[i+j]
#7
GetTable gets only HTML tag <table> tables.
#8
Try this.
Macro Macro2824
Code:
Copy      Help
out
int w=wait(3 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))
for i 0 k.len
,out k[i].Name
,
#9
Thanks a lot. It works now. Big Grin
#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 " ")


Forum Jump:


Users browsing this thread: 1 Guest(s)