Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Get the full HTML from the TWebBrowser Delphi component

Title: Get the full HTML from the TWebBrowser Delphi component When using the TWebBrowser component you might want to grab the full HTML source code from the page being displayed by the component. Here's how: ~~~~~~~~~~~~~~~~~~~~~~~~~ uses mshtml; var iall : IHTMLElement; begin if Assigned(WebBrowser1.Document) then begin iall := (WebBrowser1.Document AS IHTMLDocument2).body; while iall.parentElement nil do begin iall := iall.parentElement; end; memo1.Text := iall.outerHTML; end; end; ~~~~~~~~~~~~~~~~~~~~~~~~~ Note: HTML goes into a TMemo control named "Memo1".