把IdHTTP1的HandleRedirects置为True,是在header里面有location: http://www.***时自动转向,若在html的页面内容再有连接,那就要自己写代码分析提取了。
下面是我用蚂蚁下载上面的地址:2003/12/05 17:48:41 解析主机地址 ...
2003/12/05 17:48:42 主机地址已确认
2003/12/05 17:48:43 连接到主机 (www.jhdz.com.cn:80) ...
2003/12/05 17:48:43 成功连接到主机
2003/12/05 17:48:43 GET /personnel/patchhome/openfile.asp?TableName=patch&ID=272 HTTP/1.1
2003/12/05 17:48:43 Host: www.jhdz.com.cn
2003/12/05 17:48:43 Accept: */*
2003/12/05 17:48:43 Referer: http://www.delphibbs.com/delphibbs/dispq.asp?lid=2330355
2003/12/05 17:48:43 User-Agent: NetAnts/1.25
2003/12/05 17:48:43 Pragma: no-cache
2003/12/05 17:48:43 Cache-Control: no-cache
2003/12/05 17:48:43 Connection: close
2003/12/05 17:48:43 HTTP/1.1 302 Object moved
2003/12/05 17:48:43 Server: Microsoft-IIS/5.0
2003/12/05 17:48:43 Date: Fri, 05 Dec 2003 10:06:46 GMT
2003/12/05 17:48:43 Connection: close
2003/12/05 17:48:43 Location: http://www.kingsoft.net/download/downfile/PW2003SP3.exe
2003/12/05 17:48:43 Content-Length: 121
2003/12/05 17:48:43 Content-Type: text/html
2003/12/05 17:48:43 Set-Cookie: ASPSESSIONIDSSSDRATC=JBNHIACAFFOKLEGAIKOJPICJ; path=/
2003/12/05 17:48:43 Cache-control: private
2003/12/05 17:48:43 重定向连接到其它站点
2003/12/05 17:48:43 解析主机地址 ...
2003/12/05 17:48:43 主机地址已确认
2003/12/05 17:48:43 连接到主机 (www.kingsoft.net:80) ...
2003/12/05 17:48:43 成功连接到主机
2003/12/05 17:48:43 GET /download/downfile/PW2003SP3.exe HTTP/1.1
2003/12/05 17:48:43 Host: www.kingsoft.net
2003/12/05 17:48:43 Accept: */*
2003/12/05 17:48:43 Referer: http://www.delphibbs.com/delphibbs/dispq.asp?lid=2330355
2003/12/05 17:48:43 User-Agent: NetAnts/1.25
2003/12/05 17:48:43 Pragma: no-cache
2003/12/05 17:48:43 Cache-Control: no-cache
2003/12/05 17:48:43 Connection: close
2003/12/05 17:48:44 HTTP/1.1 200 OK
2003/12/05 17:48:44 Server: Microsoft-IIS/5.0
2003/12/05 17:48:44 Connection: close
2003/12/05 17:48:44 Date: Fri, 05 Dec 2003 09:52:43 GMT
2003/12/05 17:48:44 Content-Type: application/octet-stream
2003/12/05 17:48:44 Accept-Ranges: bytes
2003/12/05 17:48:44 Last-Modified: Wed, 19 Nov 2003 07:23:47 GMT
2003/12/05 17:48:44 ETag: "285872126eaec31:a47"
2003/12/05 17:48:44 Content-Length: 5621582
2003/12/05 17:48:44 正在接收数据...
2003/12/05 17:48:46 已被用户取消
需要注意的是:
不能这样接收非文本文件 S:=IdHTTP1.get("http://www……")
要用一个流来接收:IdHTTP1.get("http://www……",TMemoryStream)