I want to download a page from a website.
The page is located at an url like: http://www.example.com/status?param1=19439016¶m2=812554¶m3=140104010101
For download I use the code (downloaded from the internet):
function Download_HTM(const sURL, sLocalFileName:string): boolean;
begin
Result:=True;
with TDownLoadURL.Create(nil) do
try
URL:=sURL;
Filename:=sLocalFileName;
try
ExecuteTarget(nil);
except
Result:=False
end;
finally
Free;
end;
end;
my call is:
sURL := Format('%s/status?param1=%s¶m2=%s¶m3=%s',
[sWeb, param1, param2, param3]);
if Download_HTM(sURL, sLocalFile) then
....
but don't work. Also I used:
sURL := Format('%s/status?param1=%s'#38'param2=%s'#38'param3=%s',
[sWeb, param1, param2, param3]);
but don't work. I can't insert the & character in the url. Any advice?
Now, instead of Download_HTM I tried the bellow function (from a stackoverflow example):
function GetURLAsString(const aURL: string): string;
var
lHTTP: TIdHTTP;
begin
lHTTP := TIdHTTP.Create(nil);
try
Result := lHTTP.Get(aURL);
finally
lHTTP.Free;
end;
end;
but I receive: Socket error 10014 - Bad address I'm sure that my address is corect because when I put it on the internet explorer I receive the corect html page.
When I show the sURL variable with the command ShowMessage(sURL) I can see the entire url but without the & character and the character p from the param3 word is underlined (the p character follow after the last & character from the URL) and the behavoir same to be like when I use & to create a shoertcut on a menu caption !