Forum > Networking and Web Programming

Get HTML page

(1/2) > >>

xinyiman:
I have a problem, I wish I could see the html code for a specific page on the Internet, say I want to see the html page www.liuheschool.com (which is my site) as I do? I wish I could put into a string and then analyze it! Ideas Suggestions?

Peter_Vadasz:
Try ararat synapse HTTPSend Unit.
Here is an example (sorry the texts are hungarian in the example):

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

uses BaseUnix,HTTPSend,Classes,SysUtils;

var http : THTTPSend;
    page : TStringList;
    i : longint;
    talalt : boolean=true;
    mp : word;
    c: integer;

procedure help;
begin
  writeln('A program hasznalata :');
  writeln('   ./getsite url keresett_szo varakozasi_ido_masodpercben');
  writeln('    ahol az ');
  writeln('       url a weblap cime,');
  Writeln('       keresett_szo a szo amit a lapon keresunk es a');
  writeln('       varakozasi_ido_masodpercben az ido amig a program var');
  writeln('       mielott ujra keresni kezd, ha elsore megtalalta a keresett');
  writeln('       szot az oldalon');   
  writeln;
  halt(1);
end;

   
begin
  if (paramcount<3) or (pos('--HELP',UpCase(ParamStr(1)))<>0) then
    begin
      help;
      halt(1);
    end;
   
  http:=THTTPSend.Create;
  page:=TStringList.Create;
  try
    repeat
      if not http.HTTPMethod('GET',ParamStr(1)) then
        begin
          writeln('Hiba tortent!!!');
          writeln('A program kilep...');
          halt(1);
        end
      else
        begin
          page.LoadFromStream(http.Document);
          for i:=0 to page.Count-1 do
            if pos(UpCase(ParamStr(2)),UpCase(page[i]))<>0 then
              begin
                talalt:=true;
                write('Tal+ílat'+#10);
                val(ParamStr(3),mp,c);
                flush(Output);
//                writeln(TimeToStr(Time));
                fpSleep(mp);
//                writeln(TimeToStr(Time));
              end
            else talalt:=False;
        end;
        http.Clear;
        page.Clear;
      until talalt; 
  finally
    http.Free;
    page.Free;
  end;
end.
--- End code ---
This code is try to find a given text in the source of the downloaded webpage.

xinyiman:

--- Quote from: Peter_Vadasz on March 23, 2010, 11:56:54 am ---Try ararat synapse HTTPSend Unit.
Here is an example (sorry the texts are hungarian in the example):

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

uses BaseUnix,HTTPSend,Classes,SysUtils;

var http : THTTPSend;
    page : TStringList;
    i : longint;
    talalt : boolean=true;
    mp : word;
    c: integer;

procedure help;
begin
  writeln('A program hasznalata :');
  writeln('   ./getsite url keresett_szo varakozasi_ido_masodpercben');
  writeln('    ahol az ');
  writeln('       url a weblap cime,');
  Writeln('       keresett_szo a szo amit a lapon keresunk es a');
  writeln('       varakozasi_ido_masodpercben az ido amig a program var');
  writeln('       mielott ujra keresni kezd, ha elsore megtalalta a keresett');
  writeln('       szot az oldalon');   
  writeln;
  halt(1);
end;

   
begin
  if (paramcount<3) or (pos('--HELP',UpCase(ParamStr(1)))<>0) then
    begin
      help;
      halt(1);
    end;
   
  http:=THTTPSend.Create;
  page:=TStringList.Create;
  try
    repeat
      if not http.HTTPMethod('GET',ParamStr(1)) then
        begin
          writeln('Hiba tortent!!!');
          writeln('A program kilep...');
          halt(1);
        end
      else
        begin
          page.LoadFromStream(http.Document);
          for i:=0 to page.Count-1 do
            if pos(UpCase(ParamStr(2)),UpCase(page[i]))<>0 then
              begin
                talalt:=true;
                write('Tal+ílat'+#10);
                val(ParamStr(3),mp,c);
                flush(Output);
//                writeln(TimeToStr(Time));
                fpSleep(mp);
//                writeln(TimeToStr(Time));
              end
            else talalt:=False;
        end;
        http.Clear;
        page.Clear;
      until talalt; 
  finally
    http.Free;
    page.Free;
  end;
end.
--- End code ---
This code is try to find a given text in the source of the downloaded webpage.

--- End quote ---

Ok, this method is cross platform?

Peter_Vadasz:
Yes, Ararat Synapse is cross platform (I used under windows and linux).

xinyiman:
Thanks, but the parameters that you use the program that I've just posted what are they? Why I can not understand what language is and I have no idea how tested!

Navigation

[0] Message Index

[#] Next page

Go to full version