Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Synching application with browser component navigation 1

Status
Not open for further replies.

ors

Programmer
Sep 10, 2005
18
MT
I am using Delphi 5's Web Browser component to navigate a website.
I need to parse the HTML source of some web pages, but since my code and the web browser do not seem to work in synch, I cannot work on the HTML source immediately after issuing a browser.navigate command.
I tried using sleep / application.processmessages but it did not work.
Any ideas please?
 
Can't you use the WebBrowser component's DocumentComplete event to notify you when the page has finished loading?


Hopw this helps.

[vampire][bat]
 
Thanks for the help, but my problem is that in each case after triggering browser navigation, I need to do different actions.
Here's a peudo code example.


1) Cycle through grid rows.
2) For each row, navigate to a URL.
3) Parse the new page.
4) Navigate back.
5) Repeat for next row.

My problem is that step 3 takes place before step 2 finishes.
Similarly step 5 starts before step 4 is completed.

Help please.

 
I found i had to use the WebBrowserDocumentComplete event and ReadyState together.

This is how i download images from a list of url's in a listbox.

1st i have a start button that loads the first url then after that page loads the document complete event kicks in.

Code:
TMainForm.WebBrowserDocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
 If WebBrowser.ReadyState=READYSTATE_COMPLETE then
  begin
   {save image code here}
  end;
 
 URLlistbox.items.Delete(0);
 If URLlistbox.items.Count > 0 then
  {download next url code here}
end;

Aaron
 
Thanks for that. I will use it. However my original problem remains in that multiple documentcomplete2 events are triggered for every page. I believe the problem to be some HTML iframe tags. I created a seperate thread to loop and look for document completion, since leaving the loop in the main thread seemed to halt the application and browser.

Further suggestions ar very welcome.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top