Solved

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

Posted on 2014-10-03
2
550 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
[X]
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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

740 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