0

I've done things others recommended to get TDownloadURL working.

I finally boiled it all down to a form with a TButton, a TEdit, and a TMemo. Click the button to download the URL and display in the TMemo.

I get an error message:

Error Downloading URL

And weirdly, the ampersands in the URL are absent in the error message.

This is in Delphi 10.

Here is the entirety of the program code:

procedure TForm1.Button1Click(Sender: TObject);
VAR tmpname, tmpUrl : String;
begin
    Memo1.Clear;
    tmpName := 'E:\Borland Studio Projects\TryPhish\temp.tmp';
    Edit1.Text := 'http://www.phishtank.com/phish_search.php?page=1&active=y&valid=u&Search=Search';
    tmpUrl := Edit1.Text;
    WITH TDownloadURL.Create(nil) DO
    try
        URL := tmpUrl;
        filename := tmpName;
        try
            ExecuteTarget(self);
            Memo1.Lines.LoadFromFile(tmpName);
            DeleteFile(tmpName);
        except
        ON E:Exception DO
            ShowMessage(E.Message);
        end;
    finally
        Free;
    end;
end;

I used to know all this, but 10+ years of hardly doing any coding have taken their toll...

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
  • 3
    `TDownloadURL` uses Microsoft's `URLDownloadToFile()` function, which is notoriously buggy and prone to failures, and `TDownloadURL` does not report WHY it fails. You are better off using the WinInet API instead (see [HTTP Sessions](https://msdn.microsoft.com/en-us/library/windows/desktop/aa384322.aspx) on MSDN), or a third-party HTTP client, like Indy's `TIdHTTP` component. Especially if you don't want/need to download to a temp file. As for the ampersands, that is simply a side effect of the `ShowMessage` dialog, if you look at `E.Message` itself you will see they do exist in the string data – Remy Lebeau Feb 28 '18 at 22:27
  • As a side-note, I couldn't help but to notice the Borland reference. I can imagine that either you are only recently introduced to newer versions of Delphi, or have not gotten around to removing the reference to Borland, or have a bunch of code in there which uses absolute paths instead of relative paths... – Jerry Dodge Mar 01 '18 at 01:32
  • Jerry Dodge, it really is Borland Turbo Delphi. Like I said, I stopped coding ages ago, now only doing maintenance when OS changes give me trouble. I have no time-budget for coding; what I do is review and evaluate consumer-facing security products for PCMag.com. I'm quite sure that updating to a newer compiler would mean weeks of learning the differences and updating the simple programs I use in testing. SO... I patch and patch. – neiljrubenking Mar 01 '18 at 14:30

0 Answers0