MissouriTiger
Programmer
I am at my wits end! I know this sounds like an easy question, but I have tried this a hundred ways, and cannot find a way that works and that is practical. Please, somebody help me solve this problem.
My program grabs 3 web pages (one at a time), parses the html to determine if a number on the page has changed, then does it all over again, continuously until a change is detected.
Unfortunatley, I cannot use the Inet control, because the html that the Inet control gets from the server isn't quite the same as what the browser gets, probably due to an idenitty issue (maybe cookie?).
Anyway, I have to use the browser control and get the html from there.
So, I need to do something like this:
................
objBrowser.Navigate someURL
strHTML = objBrowser.Document.body.outerHTML
strResult = GetBetween(strHTML, strStartDelim, strEndDelim)
.................
Seems really simple, right?
Wrong. This code doesn't work, because it executes too quickly, before the browser is finished downloading the HTML.
I realize that I could just end the procedure and then rely on the objBrowser_DocumentComplete() event to execute the rest of the code, but then I would lose the flow of the program. What if the DocumentComplete() event never fires? My program will hang.
So, I tried adding a variety of different loops to wait for the page to download, such as the following:
.........................
objBrowser.Navigate someURL
Do While objBrowser.Busy
Do stuff
Loop
strHTML = objBrowser.Document.body.outerHTML
strResult = GetBetween(strHTML, strStartDelim, strEndDelim)
.........................
But that just causes an infinite loop, and the program has to be forced to quit. As long as the loop is running, the browser won't finish loading the page.
I also tried loops like these:
......................
Do Until (objBrowser.LocationURL = strCurrentURL)
Do stuff
Loop
......................
......................
'This one waits for the DocumentComplete() event to
' set the blnPageLoaded variable to TRUE.
Do Until blnPageLoaded
Do stuff
Loop
......................
NOTHING WORKS!!!
As long as the loop is running, the browser never finishes, the DocumentComplete event never fires, so a loop seems to be out of the question, unless I can somehow start it in a seperate thread, but I've never done multi-threading in VB and I question whether multi-threading is even apropriate here.
Isn't there some way to trap the DocumentComplete event inside my procedure? Or something? I just need for my program to pause momentarilly until the page is loaded.
Please help! By the time I get this program finished my hourly rate will be $2.00 an hour!
Greg Norris
Software Developer
________________________________________________
Constructed from 100% recycled electrons.
My program grabs 3 web pages (one at a time), parses the html to determine if a number on the page has changed, then does it all over again, continuously until a change is detected.
Unfortunatley, I cannot use the Inet control, because the html that the Inet control gets from the server isn't quite the same as what the browser gets, probably due to an idenitty issue (maybe cookie?).
Anyway, I have to use the browser control and get the html from there.
So, I need to do something like this:
................
objBrowser.Navigate someURL
strHTML = objBrowser.Document.body.outerHTML
strResult = GetBetween(strHTML, strStartDelim, strEndDelim)
.................
Seems really simple, right?
Wrong. This code doesn't work, because it executes too quickly, before the browser is finished downloading the HTML.
I realize that I could just end the procedure and then rely on the objBrowser_DocumentComplete() event to execute the rest of the code, but then I would lose the flow of the program. What if the DocumentComplete() event never fires? My program will hang.
So, I tried adding a variety of different loops to wait for the page to download, such as the following:
.........................
objBrowser.Navigate someURL
Do While objBrowser.Busy
Do stuff
Loop
strHTML = objBrowser.Document.body.outerHTML
strResult = GetBetween(strHTML, strStartDelim, strEndDelim)
.........................
But that just causes an infinite loop, and the program has to be forced to quit. As long as the loop is running, the browser won't finish loading the page.
I also tried loops like these:
......................
Do Until (objBrowser.LocationURL = strCurrentURL)
Do stuff
Loop
......................
......................
'This one waits for the DocumentComplete() event to
' set the blnPageLoaded variable to TRUE.
Do Until blnPageLoaded
Do stuff
Loop
......................
NOTHING WORKS!!!
As long as the loop is running, the browser never finishes, the DocumentComplete event never fires, so a loop seems to be out of the question, unless I can somehow start it in a seperate thread, but I've never done multi-threading in VB and I question whether multi-threading is even apropriate here.
Isn't there some way to trap the DocumentComplete event inside my procedure? Or something? I just need for my program to pause momentarilly until the page is loaded.
Please help! By the time I get this program finished my hourly rate will be $2.00 an hour!
Greg Norris
Software Developer
________________________________________________
Constructed from 100% recycled electrons.