I use Borland Turbo C++ (like Builder c++ but less components).
When i do Webbrowser1->Navigate(MyURL) I receive the demanded website properly. In my case it is only a text website, not even html code. I can see it in the Webbrowser's window.
How do I access the received text to be able to manipulate it, count number of chars etc? Best case would be if i can make it into an Ansistring.
I don't have any idea how to do it. Which class do I use or what type to try to convert to.
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.