Solved

[delphi] [Web Browser] if text available in web page then ?

Posted on 2014-10-03
2
540 Views
Last Modified: 2014-10-04
i want to find text in web page and if it's available then show message ('text available')
Thanks
0
Comment
Question by:napster matheo
2 Comments
 

Accepted Solution

by:
napster matheo earned 0 total points
ID: 40361258
i solve it , Thank you experts
i have got source code of web page then i putted it in Tmemo Then search in memo using the following functions
Search function :
type
  TSearchOption = (soIgnoreCase, soFromStart, soWrap);
  TSearchOptions = set of TSearchOption;


function SearchText(
    Control: TCustomEdit; 
    Search: string; 
    SearchOptions: TSearchOptions): Boolean;
var
  Text: string;
  Index: Integer;
begin
  if soIgnoreCase in SearchOptions then
  begin
    Search := UpperCase(Search);
    Text := UpperCase(Control.Text);
  end
  else
    Text := Control.Text;

  Index := 0;
  if not (soFromStart in SearchOptions) then
    Index := PosEx(Search, Text, 
         Control.SelStart + Control.SelLength + 1);

  if (Index = 0) and 
      ((soFromStart in SearchOptions) or 
       (soWrap in SearchOptions)) then
    Index := PosEx(Search, Text, 1);

  Result := Index > 0;
  if Result then
  begin
    Control.SelStart := Index - 1;
    Control.SelLength := Length(Search);
  end;
end;

Open in new window


===========
get source code of web browser code :
procedure WB_SaveAs_HTML(WB : TWebBrowser; 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;
procedure TForm4.wb1DocumentComplete(Sender: TObject;

Open in new window


========

How to use codes :  
 WB_SaveAs_HTML(wb1 , 'res.txt');
    mmo2.Lines.LoadFromFile('res.txt') ;

  if  SearchText(mmo2 , '[Welcome]' , []) = true then
  begin
end;

That's all
Bye.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Firemonkey webbrowser scrollbars ? 1 56
Message not shown 5 82
Problem to App 4 115
Problem to refer to value 8 77
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to implement Singleton Design Pattern in Java.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question