return displayed text in embeddedwb



how do i get the text that is displayed in embeddedwb  browser?


i try this:

   document := web.document as IHTMLDocument2;
   memo1.Clear;
   memo1.lines.add(trim(document.body.innertext));  // to get text
   memo1.lines.savetofile('test2.txt')

it returns 2 blank lines

i try this:

procedure tform1.WB_SaveAs_HTML(WB : tembeddedwb; const FileName : string) ;
var
  PersistStream: IPersistStreamInit;
  Stream: IStream;
  FileStream: TFileStream;
begin
  if not Assigned(WB.Document) then
  begin
    ShowMessage('Document not loaded!') ;
    Exit;
  end;

  PersistStream := WB.Document as IPersistStreamInit;
  FileStream := TFileStream.Create(FileName, fmCreate) ;
  try
    Stream := TStreamAdapter.Create(FileStream, soReference) as IStream;
    if Failed(PersistStream.Save(Stream, True)) then ShowMessage('SaveAs HTML fail!') ;
  finally
    FileStream.Free;
  end;
end; (* WB_SaveAs_HTML *)

it returns--  SaveAS HTML fail

it is displayed on the screen - there must be a way to save it to file???
arwar49Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mahdi78Commented:
try this

procedure TForm1.WebBrowser1DocumentComplete(ASender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
Memo1.Text := WebBrowser1.OleObject.Document.documentElement.innerText;
end;
0
arwar49Author Commented:
i can't use that because i don't have a URL to feed it. I navigate to the home page and then have to drill down to section(s) i am looking for.  I need something that i can call after i have navigated - the url never changes from the top level.
0
Mahdi78Commented:
Can you explain more?
You can use my even with button click like htis

procedure TForm1.Button2Click(Sender: TObject);
begin
 Memo1.Text := WebBrowser1.OleObject.Document.documentElement.innerText;
end;
0
arwar49Author Commented:
all it returns is the html title tag
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arwar49Author Commented:
it wasn't solved - i just want the question closed
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.