Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting table from JavaScript
#6
Unstable. The first time it retrieved whole filled table. Then either empty table (335 length) or did not work.
Then I tried with a visible WebBrowser control in a dialog. At first did not work. Now works. Don't know why.
Then also tried the script, and it did not work, but after adding opt waitmsg 1 now it works.

Macro Macro2753
Code:
Copy      Help
opt waitmsg 1
int minLength=500
HtmlDoc d
d.SetOptions(2)
;g1
d.InitFromWeb("http://www.imea.com.br/imea-site/indicador-milho")

rep 10 ;;wait for the javascript to finish
,1
,str s=d.GetHtml("tbody" "body-milho-disponivel")
,out s.len ;;335 when empty, 5308 when full
,if(s.len>=minLength) break
,out "waiting"
if(s.len<minLength)
,out "RETRY"
,goto g1

out s

Function Dialog204
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 754 404 "Dialog"
;3 ActiveX 0x54030000 0x0 0 16 754 388 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;4 Button 0x54032000 0x0 0 0 50 14 "QM forum"
;5 Button 0x54032000 0x0 56 0 48 14 "IMEA"
;END DIALOG
;DIALOG EDITOR: "" 0x2040400 "*" "" "" ""

str controls = "3"
str ax3SHD
ax3SHD="http://www.imea.com.br/imea-site/indicador-milho"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
SHDocVw.WebBrowser we3
we3._getcontrol(id(3 hDlg))
sel wParam
,case 4
,we3.Navigate("http://www.quickmacros.com/forum")
,case 5
,we3.Navigate("http://www.imea.com.br/imea-site/indicador-milho")
ret 1


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)