ASP HTTP 使用范例
發(fā)表時(shí)間:2024-02-18 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]簡(jiǎn)單實(shí)例: 使用這個(gè)組件十分簡(jiǎn)單 1.創(chuàng)建對(duì)象 2.設(shè)定一些屬性 3.調(diào)用GetUrl方法 下面是vbscript使用AspHTTP的示例代碼 Set HttpObj = Server.CreateObject("AspHTTP.Conn") HttpObj.Url = &qu...
簡(jiǎn)單實(shí)例:
使用這個(gè)組件十分簡(jiǎn)單
1.創(chuàng)建對(duì)象
2.設(shè)定一些屬性
3.調(diào)用GetUrl方法
下面是vbscript使用AspHTTP的示例代碼
Set HttpObj = Server.CreateObject("AspHTTP.Conn")
HttpObj.Url = "http://www.myfinancialpage.com/qrtresults.html"
strResult = HttpObj.GetURL
變量strResult現(xiàn)在包含一個(gè)字符串從http://www.myfinancialpage.com/qrtresults.html
GET獲得的文檔結(jié)果
實(shí)例:獲得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>"
%>
實(shí)例:處理和顯示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> (出處:熱點(diǎn)網(wǎng)絡(luò))