0

I'm using IdHTTP for a simple Get request:

procedure TForm1.FormCreate(Sender: TObject);
const
  URL = 'https://www.udemy.com/course/the-modern-angular-bootcamp/';
begin
  IdSSLIOHandler.SSLOptions.Method := sslvSSLv23;
  IdHttp1.Request.UserAgent :=
      'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0';

  Memo1.Lines.Text := IdHTTP1.Get(URL);

The call to IdHTTP1.Get results in the error "HTTP/1.1 403 Forbidden".

A similar question (Why do I get "403 Forbidden" when I connect to whatismyip.com?) says the UserAgent should be set to a modern value. I have done so, but it does not help.

I'm using OpenSSL Win32 v1.0.2u. Tokyo, Windows 10

Similar code using THttpClient works without any problem:

HttpClient := THTTPClient.Create;
try
  Response := HttpClient.Get(URL);
  Memo1.Lines.Text := Response.ContentAsString();
finally
  HttpClient.Free;
end;
RaelB
  • 3,301
  • 5
  • 35
  • 55
  • `Firefox/12.0` is not a modern browser. Try this one: `Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0` – zed Feb 03 '20 at 14:32
  • Thanks for the suggestion - however, same result. – RaelB Feb 03 '20 at 14:39
  • Could be SSL related. Indy also tends to get specifically targeted with a lot of anti-scraping hacks, but usually this happens at the user-agent level (which you're changing...). If you're trying to scrape the site, be sure this isn't in violation of their terms of use. – J... Feb 03 '20 at 15:31

0 Answers0