views:

117

answers:

1

I'm doing a little (or at least I'm hoping it's little) favor for a friend, but haven't used Delphi in 10 or so years... and my searches haven't been of much use

What I'm trying to do is to GET an URL and then parse the HTML to find some info he needs. I'm hoping for something like this (in python) fileHandle = urllib2.urlopen(urlStr) and fileHandle would receive the HTML of the page I requested. All examples I found opened the default browser, but

I'm using linux, with Lazarus and Free Pascal, he is using Delphi 7 (if I recall correctly) if that matters at all.

Thanks.

+6  A: 

Using Indy you can use the TidHttp Component.

var
  http : TidHttp;
  page : String;
begin
  http := TidHttp.Create(nil);
  try
  page := http.get(URL);
  finally 
    http.Free;
  end;
end;

Get has several overloaded versions if you desired the contents in other formats and need to pass additional informaiton.

Robert Love
Note that this works with Lazarus too, only as a rule of thumb, non windows FPC only works with Indy10.
Marco van de Voort