Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML plain text search. How?

Status
Not open for further replies.

astar

Technical User
Nov 4, 2001
3
US
Here is what I want to do:
After opening some site search for a string in its content(not in its source, just in the site itself) and check/not check a Checkbox depending on the search result. After that go to some other site, search again...All that auto- matically. But I can't copy the text from the site to search in it.
I've tried to use THTML but it can't retrieve domain sites, nor can it use Java scripts(or at least I think so).
TWebBrowser solved that problem but does not have property like GetPlainText to copy the site's text. So what should I use to copy the text?
Thank you in advance.


 
Do u know ASP(VB script), JSP(JScript), CGI(perl) or some of them.
I've never try it but take a look to this maybe with just javascript or vb script u can do it.
Look for this character on the web ?, with it u pass parameter and variable values true internet pages.
For example:
But as U see I used asp then inside the page with "Request"
and object in ASP I get those values.
 
Have a look at this to see if it will help you out.
In this example I have the raw HTML held in memo1 end decode it to memo2.

This function could then be made more inteeligebt as you wish (for example only wtiting a line on
Code:
<BR>
)


Code:
procedure TForm1.Button1Click(Sender: TObject);
var
   myHTML, myText  : String;
   loop1, loop2 : Integer;
   toWrite : Boolean;
   x : char;
begin
   toWrite :=  True;
   for loop1:= 1 to memo1.Lines.Count do  
   begin
      myText := '';
      myHTML := memo1.Lines[loop1];
      for loop2 := 1 to length(myHTML) do
      begin
         x:= myHTML[loop2];
         if x = '<' then toWrite := false;
         if toWrite then myText := myText + x;
         if x = '>' then toWrite := True;
      end;
      if Length(myText) > 0 then memo2.Lines.Add(myText);
   end;
end;
[code]

X-) Billy H

bhogar@acxiom.co.uk
 
Have a look at the folowing code this copies the source from a URL to a TMemo (or other String container). you will need to include wininet in your uses list.

This makes use if the WinInet.DLL provided by microsoft os part of the Windows operating system. This DLL impliments FTP and HTTP protocols on top of the Windows sockets API

Calls are:-
InternetOpen
InternetOpenURL
InternetReadFile


Hope this is of help



Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  hSession, hReqURL : HInternet;
  Buffer: Array[0..1024] of Char;
  BufferLength: DWORD;
  URL, tmpStr: String;
  loop : Integer;
begin
  URL := '[URL unfurl="true"]http://www.inprise.com/';[/URL]
  hSession := InternetOpen('BillyH',INTERNET_OPEN_TYPE_PRECONFIG,nil,nil,0);
  try
     hReqURL := InternetOpenURL(hSession, PChar(URL), nil,0,0,0);
     try
        repeat
           InternetReadFile(hReqURL, @Buffer, sizeOf(Buffer), BufferLength);
           tmpStr := '';
           tmpStr := tmpStr + string(buffer);
           memo1.Lines.Add(tmpStr);
        until BufferLength = 0;
     finally
        InternetCloseHandle(hReqURL)
     end
  finally
    InternetCloseHandle(hSession)
  end
end;

X-) Billy H

bhogar@acxiom.co.uk
 
I’ve now worked out how to do it the way you were trying, by copying to the clipboard. Have a look at the following text.

Please Note:


The inclusion of ‘ActiveX’ in the uses section.
The initialisation statement
And its counterpart of the finalization statement


Hope this is of use.

Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, OleCtrls, SHDocVw, ActiveX;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    Button1: TButton;
    Memo1: TMemo;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure WebBrowser1ProgressChange(Sender: TObject; Progress,
      ProgressMax: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.Button1Click(Sender: TObject);
begin
   WebBrowser1.GoHome;
end;

procedure TForm1.WebBrowser1ProgressChange(Sender: TObject; Progress,
  ProgressMax: Integer);
var
loop : Integer;
begin
  if progress= -1 then
  begin
     WebBrowser1.ExecWB(OLECMDID_SELECTALL,0);
     WebBrowser1.ExecWB(OLECMDID_COPY,0);
  end;
end;

initialization
OleInitialize(nil);

finalization
OleUnInitialize;

end.


X-)
Billy H

bhogar@acxiom.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top