【问题标题】:Get web page in Delphi [duplicate]在Delphi中获取网页[重复]
【发布时间】:2011-05-15 10:28:18
【问题描述】:
【问题讨论】:
标签:
delphi
parsing
download
【解决方案1】:
要添加到 Andreas cmets,您还可以查看 Delphi.About.com,那里有一个下载文件并显示进度条的示例:http://delphi.about.com/cs/adptips2003/a/bltip0903_2.htm
"如果您需要将指定 URL 的内容保存到文件中 - 并且能够跟踪下载进度,请使用 TDownLoadURL Delphi 操作
TDownLoadURL 在写入指定文件时,会定期生成 OnDownloadProgress 事件,以便您可以向用户提供有关该过程的反馈。
这是一个示例 - 请注意,您必须在 uses 子句中包含单位 ExtActns。”
uses ExtActns, ...
type
TfrMain = class(TForm)
...
private
procedure URL_OnDownloadProgress
(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String; var Cancel: Boolean) ;
...
implementation
...
procedure TfrMain.URL_OnDownloadProgress;
begin
ProgressBar1.Max:= ProgressMax;
ProgressBar1.Position:= Progress;
end;
function DoDownload;
begin
with TDownloadURL.Create(self) do
try
URL:='http://0.tqn.com/6/g/delphi/b/index.xml';
FileName := 'c:\ADPHealines.xml';
OnDownloadProgress := URL_OnDownloadProgress;
ExecuteTarget(nil) ;
finally
Free;
end;
end;