First navigate to MyURL:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
WebBrowser1->Navigate(MyURL);
}
Put retrieve codes in OnDocumentComplete event:
void __fastcall TForm1::WebBrowser1DocumentComplete(TObject *Sender, LPDISPATCH pDisp,
Variant *URL)
{
Variant document = WebBrowser1->Document;
Variant body = document.OlePropertyGet("body");
Variant parentElement = body.OlePropertyGet("parentElement");
AnsiString html = parentElement.OlePropertyGet("outerHTML");
Memo1->Text = html;
}
Or briefly:
Memo1->Text = Variant(WebBrowser1->Document).OlePropertyGet("body").OlePropertyGet("parentElement").OlePropertyGet("outerHTML");
Note that you can simply send http request and retrieve response text without TWebBrowser.