如何查找并下载网页中所连接的资源,如rar,zip等?

WindowsAPI 2004-09-29 12:03:37
如何查找并下载网页中所连接的资源,如rar,zip等。就像网络蚂蚁或网际快车那样。
...全文
194 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
海天候 2004-09-30
  • 打赏
  • 举报
回复
把我要说的给抢了
masterjames 2004-09-30
  • 打赏
  • 举报
回复
同意楼上
cronuz 2004-09-30
  • 打赏
  • 举报
回复
uses UrlMon;

function DownloadFile(SourceFile, DestFile: string): Boolean;
begin
try
Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;
except
Result := False;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i,j: Integer;
Source,Dest,ext: OleVariant;
begin
WebBrowser1.Navigate('http://www.xxx.com');
while WebBrowser1.ReadyState < READYSTATE_COMPLETE do
Application.ProcessMessages;

if WebBrowser1.OleObject.Document.all.tags('A').Length = 0 then Exit;
Memo1.Clear;

for i := 0 to WebBrowser1.OleObject.Document.all.tags('A').Length - 1 do
begin
Source := WebBrowser1.OleObject.Document.all.tags('A').Item(i);
j := LastDelimiter('.', Source);
ext := UpperCase(Copy(Source, j+1, Length(Source)));

if (ext = 'RAR') or (ext = 'ZIP') then
begin
Memo1.Lines.Add(Source.innerText + ': ' + Source.href);
Dest := ExtractFilePath(ParamStr(0)) + Source.innerText;
DownloadFile(Source, Dest);
end;
end;
end;

説明:用「TWebBrowser」控件、下载网页中<a href="...">
SuanAddMiao 2004-09-29
  • 打赏
  • 举报
回复
不明白,帮你UP一下.

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧