Forum > Networking and Web Programming

Get HTML page

<< < (2/2)

Peter_Vadasz:
First, Sorry for my bad english.

The program that I posted is a simple free pascal program. You can use it, if you give 3 parameters in the command line. The first parameter is the URL of the site that you want to check. The second parameter is a word (sort text) that the program is try to find in the source code of the webpage (which was given in the first parameter) and the third parameter is a number.  If the program found the given text (second parameter) in the webpage then check again the URL every number seconds (third parameter) while the text (second parameter) is found on the page.
I wrote in my first post that the program contains Hungarian texts.
Here is the english version of the program:

--- Code: ---{$MODE objfpc}{$H+}
program getsite;

uses BaseUnix,**Send,Classes,SysUtils;

var ** : T**Send;
    page : TStringList;
    i : longint;
    talalt : boolean=true;
    mp : word;
    c: integer;

procedure help;
begin
  writeln('Usage :');
  writeln('   ./getsite url word second');
  writeln('    where ');
  writeln('       url is the URL of a webpage,');
  Writeln('       word is a short text (only 1 word) that we want to find in the site');
  writeln('       second is time in second while the program waits before the next search if it found the word in the first/previous search');
  writeln;
  halt(1);
end;

   
begin
  if (paramcount<3) or (pos('--HELP',UpCase(ParamStr(1)))<>0) then
    begin
      help;
      halt(1);
    end;
   
  **:=T**Send.Create;
  page:=TStringList.Create;
  try
    repeat
      if not **.**Method('GET',ParamStr(1)) then
        begin
          writeln('Error!!!');
          writeln('Program halted');
          halt(1);
        end
      else
        begin
          page.LoadFromStream(**.Document);
          for i:=0 to page.Count-1 do
            if pos(UpCase(ParamStr(2)),UpCase(page[i]))<>0 then
              begin
                talalt:=true;
                write('Found'+#10);
                val(ParamStr(3),mp,c);
                flush(Output);
//                writeln(TimeToStr(Time));
                fpSleep(mp);
//                writeln(TimeToStr(Time));
              end
            else
            begin
              talalt:=False;
            end; 
        end;
        **.Clear;
        page.Clear;
      until not talalt;
  finally
    **.Free;
    page.Free;
  end;
end.

--- End code ---

xinyiman:
Thank you!

Navigation

[0] Message Index

[*] Previous page

Go to full version