【www.gdgbn.com--php安装】

在本教程,我们将使用微软的XMLHTTP请求对象的网页远程地址从我们的服务器。这个对象包含在微软的XML的DOM组成部分,这可能是安装在您的服务器。

传统使用的微软的XMLHTTP对象是访问远程XML文件。在此基础教程,我们将用它来获取文字代码从一台远程服务器。这将是相同的信息我们的浏览器会在访问该网页。

例如在波纹管,我们已成立一个变量命名GotothisURL其中包含的网页的网址,我们将要求我们的服务器访问。应对这次访问将保存到变量ResponsePage 。

<% 

 GotothisURL = "http://www.111cn.net


 Set GetConnection = CreateObject("Microsoft.XMLHTTP") 

 GetConnection.Open "get", GotothisURL, False
 GetConnection.Send 

 
 ResponsePage = GetConnection.responseText


 Response.write (ResponsePage)

 Set GetConnection = Nothing
 %>

在avobe例如,我们可能会使用一个网址像http://111cn.net/mon/106/2e4f88e33c382feac03367f26ab889ad.htm。上面的例子将与获得的方法。您可以尝试http://www.google.asp?q=asp寻找ASP在谷歌搜索引擎( unfortunatelly是不合法地这样做访问他们的网站上,除非我们使用的方法显示在脚本波纹管) 。

在上面的例子中,我们要求所有的内容页的答复,但它可能只要求头(检查代码大胆的剧本) ,但我们可以要求只对特定的标题。您将需要更改12号线在脚本:

ResponsePage = GetConnection.getallResponseHeaders
网页的反应将一些与此类似:
服务器: Microsoft-IIS/5.0日期:周四, 2002年4月31日14时25分20秒格林尼治标准时间MicrosoftOfficeWebServer : 5.0_Pub连接:保持活动连接:
保活内容长度: 11063内容类型:文本/的HTML高速缓存控制:私营

我们还可以请求特定部分的信息包括标题(定期检查:

ResponsePage = GetConnection.getResponseHeader("Server")

To request for Date:
ResponsePage = GetConnection.getResponseHeader("Date")

To request for Content Length:
ResponsePage = GetConnection.getResponseHeader("Content-Length")

 

<%
 " 要取得的地址
 GotothisURL = http://www.111cn.net 

 " 创建XML对象
 Set GetConnection = CreateObject("Microsoft.XMLHTTP")
 " 连接主机
 GetConnection.Open "get", GotothisURL, False
 on error resume next
 GetConnection.Send 

 " ResponsePage的反应我们会在访问 
 ResponsePage = GetConnection.responseText

" 开始写
if ResponsePage="" then 
Response.write("The page is not available")
else
Response.write(ResponsePage)
end if

 Set GetConnection = Nothing
 %>

本文来源:http://www.gdgbn.com/jiaocheng/18248/