?
Solved

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

Posted on 2014-10-03
2
Medium Priority
?
576 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

752 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