How to access a webpage with ajax content in IE via COM?

I access a webpage through an IE controlled via COM interface with AHK. In this case the facebook group page, where the groups are dynamically loaded via ajax. But i got the same problem with other pages, too.

The code simplified

wb := ComObjCreate("InternetExplorer.Application")

wb.navigate("www.facebook.com/bookmarks/groups")

wb.visible := true

While wb.readyState!=4 && wb.busy
{
    Sleep 50
}

sleep 1000

source := wb.document.getElementsByTagName("body")[0].innerHTML

The Question

I get the initial HTML code, but without the DOM manipulations (i.e. the added groups). Changing the waiting time or scrolling the webpage down in IE does not change this. How can i access the final/manipulated DOM? I would prefer to use the COM interface and do not interact with the IE directly or use POST requests directly.

Thanks in advance.

Answers


Sometimes only the index number will do. In this case, you can find the Index element with "Groups" in it (there may be two of them, for me, one in the side bar and one on the main section) by iterating through all the elements and then back up a couple of elements (somewhere between 4 and 8 -- I used 4 -- should show you what you want) to find the containing element with the list of group names in it. Something like this:

    ; source := wb.document.getElementsByTagName("body")[0].innerHTML
    i = 0
    loop, % wb.document.all.length
       {
       source := wb.document.all(a_index).innerHTML
       IfEqual, source, Groups
          {
          i += 1
          ifequal i, 2
             {
             source := wb.document.all((a_index - 4)).innerHTML
             break
             }
          }
       }
    msgbox %source%

Hth,


Need Your Help

Android : How to make a spinner disabled look disabled

android android-widget android-spinner

Possible duplicate of How do I make a Spinner's "disabled" state look disabled?.