Search code examples
delphidelphi-7indy

Using IdHTTP to download web page, even if error occurs


I want to use the Indy IdHTTP component to fetch two web sites and compare them. Is it possible to use Indy to download the webpage source, even with 404 or any >200 error is found? So if there is any text on the page, no matter if there is any error, I want to download it.


Solution

  • If TIdHTTP receives a response code that results in an EIdHTTPProtocolException exception being raised, you can access the page's text from the EIdHTTPProtocolException.ErrorMessage property.