Solved

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

Posted on 2014-10-03
2
503 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 44
EvenOdd challenge 10 83
sumHeights2  challenge 7 76
VOB to mp3 8 43
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now