Extract text from a web page displayed in TWebBrowser

I am using delphi 7 and I would like to extract ONLY the text displayed on the web page directly from the web page displayed in TWebBrowser (no images ....). Can this be done and how can I do it?

+3
source share
2 answers

I used the following ...

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
 var
  Document: IHtmlDocument2;
begin
  edit1.text:=url;
  document := webbrowser1.document as IHtmlDocument2;
  memo2.lines.add(trim(document.body.innerhtml));  // to get html
  memo1.lines.add(trim(document.body.innertext));  // to get text
end;
+6
source

TRichEdit, WPTools, HTML RTF. (, , ).

+1

Source: https://habr.com/ru/post/1730387/


All Articles