简单实例:
使用这个组件十分简单
1.创建对象
2.设定一些属性
3.调用geturl方法
下面是vbscript使用asphttp的示例代码
set httpobj = server.createobject("asphttp.conn")
httpobj.url = "http://www.myfinancialpage.com/qrtresults.html"
strresult = httpobj.geturl
变量strresult现在包含一个字符串从http://www.myfinancialpage.com/qrtresults.html
get获得的文档结果
实例:获得gif文件
<%
rem this demo pulls a gif image from www.microsoft.com
server.scripttimeout = 240
set httpobj = server.createobject("asphttp.conn")
httpobj.url = "http://www.microsoft.com/library/images/gifs/toolbar/write.gif"
httpobj.followredirects = false
httpobj.requestmethod = "get"
httpobj.useragent = "mozilla/2.0 (compatible; msie 3.0b; windows nt)"
httpobj.savefileto = "c:\write.gif"
httpobj.geturl
response.write "<hr><h3>headers received</h3><pre>" & httpobj.headers & "</pre>"
%>
实例:处理和显示url包含的href
<html>
<body>
<%
server.scripttimeout = 240
set httpobj = server.createobject("asphttp.conn")
httpobj.url = "http://www.genusa.com/asp/tools.html"
httpobj.requestmethod = "get"
httpobj.useragent = "mozilla/2.0 (compatible; msie 3.0b; windows nt)"
strresult = httpobj.geturl
response.write "<h2>a href list</h2>"
varhrefarray = httpobj.gethrefs
inthrefarraylimit = ubound(varhrefarray) -1
for i = 0 to inthrefarraylimit
response.write varhrefarray(i) & "<br>" & vbcrlf
next
%>
</body>
</html>
