Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Saving a Div from WebPage
#1
Hi Guys,

I'd like to save a table from this webpage "http://finance.yahoo.com/market-overview/" in my computer using a macro.

The table html Id is "marketmoversgs-tab1".(table Market Movers)

How can I do that without opening the Browser? I want to run that macro in 2nd plan.

Thanks for helping,
#2
The "Market Movers" table often is missing in the page, need to reload the page, sometimes many times.

Macro Macro2768
Code:
Copy      Help
out
HtmlDoc d
;d.SetOptions(2) ;;makes worse
;g1
d.InitFromWeb("http://finance.yahoo.com/market-overview/")

rep 10 ;;wait for the javascript to finish
,0.1
,str s=d.GetHtml("div" "marketmoversgs-tab1")
,err out "waiting"; continue
,break
if(!s.len)
,out "RETRY"
,goto g1
,;out
,;s=d.GetHtml(); out s
,;end "failed"
out s
#3
It worked. Thanks for helping.

But do you how can I save in my computer as a table (as shown in the site) ?

Maybe it could save as .xls or .cvs or xml ...
#4
Gets the table from the div HTML and converts to CSV. Add this code to the end of previous macro.

Macro Macro2768
Code:
Copy      Help
HtmlDoc k.InitFromText(s)
ARRAY(str) a
k.GetTable(0 a)
int i nc=7
ICsv x._create; x.ColumnCount=nc
for i 0 a.len/nc
,str& firstCell=a[i*nc]
,firstCell.rtrim("")
,x.AddRowSA(i nc &firstCell)

str csv; x.ToString(csv); out csv
;x.ToFile("...")
#5
Perfect!

Thanks a lot!!!!!!! :mrgreen:


Forum Jump:


Users browsing this thread: 1 Guest(s)