我正在尝试将文件下载到字符串:
function FetchUrl(const url: string): string;
var
idhttp : TIdHTTP;
begin
idhttp := TIdHTTP.Create(nil);
try
Result := idhttp.Get(url);
finally
idhttp.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
这段代码有什么问题?我得到一个例外:HTTP/1.1 302 Found
Rem*_*eau 10
将TIdHTTP.HandleRedirects属性设置为True.默认情况下为False.
function FetchUrl(const url: string): string;
var
idhttp : TIdHTTP;
begin
idhttp := TIdHTTP.Create(nil);
try
idhttp.HandleRedirects := True;
Result := idhttp.Get(url);
finally
idhttp.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4452 次 |
| 最近记录: |