Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2014-10-03
2
531 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

840 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