ASP HTTP 使用范例
类别: ASP教程
简单实例:
使用这个组件十分简单
1.创建对象
2.设定一些属性
3.调用GetUrl方法
下面是vbscript使用AspHTTP的示例代码
Set HttpObj = Server.CreateObject("AspHTTP.Conn")
HttpObj.Url = "http://www.etoow.com/qrtresults.html"
strResult = HttpObj.GetURL
变量strResult现在包含一个字符串从http://www.etoow.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.fcxx.net/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>
使用这个组件十分简单
1.创建对象
2.设定一些属性
3.调用GetUrl方法
下面是vbscript使用AspHTTP的示例代码
Set HttpObj = Server.CreateObject("AspHTTP.Conn")
HttpObj.Url = "http://www.etoow.com/qrtresults.html"
strResult = HttpObj.GetURL
变量strResult现在包含一个字符串从http://www.etoow.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.fcxx.net/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>
- 上一篇: 为字符串中的网址加上链接的程序例子
- 下一篇: 用HTML格式发送邮件
-= 资 源 教 程 =-
文 章 搜 索