脚本宝典收集整理的这篇文章主要介绍了asp下利用XMLHTTP 从其他页面获取数据的代码,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
利用XMLHTTP&nbs
p;从其他页面获取数据
我们在编写ASP代码的时候,大家都
知道可以通过post
或者get获得form表单的数据,那么我们如何直接获得其他页面上的数据呢?这就要借助x
MLhttp协议了。xmlhttp是xmldom技
术的一部分。
下面的代码就是一个很
简单的例子,我们利用xmlhttp技术,把http://www.xxxx
.COM/站点首页的代码以xml的形式完全获取,并且在页面中输出。
<%
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.O
PEn "GET", "http://www.codetoad.com/", False
' Pull the data
From the web page
xml.Send
Response.wr
ITe "Here's the html we now have in our xml object"
Response.write "<
br><BR><BR>"
Response.Write "<xmp>"
Response.Write xml.responseText
Response.Write "</xmp>"
Response.write "<BR><BR><BR>"
Response.write " Now here's how the page looks:<BR><BR>"
Response.Write xml.responseText
Set xml = Nothing
%>
下面是另一个实例
<%
dim objHTTP , objXML , objXSL
set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objHTTP.open "GET", "http://p.moreover.com/cgi-local/page?c=Pop%20music%20
reviews&
amp;o=xml", false
objHTTP.send
set objXML = objHTTP.responseXML
set objXSL=Server.CreateObject("microsoft.xmldom")
objXSL.async=false
objXSL.load(Server.MapPath("style.xsl"))
if (objXSL.parseError.errorCode = 0) then
Response.Write(objXML.transformnode(objXSL))
else
Response.Write "Error: " & objXSL.parseError.reason & " URL:" & objXSL.url
end if
Set objHTTP = Nothing
Set objXML = Nothing
Set objXSL = Nothing
%>
style.xsl:
<xsl:stylesheet xmlns:xsl="http://www.w3.
org/TR/WD-xsl">
<xsl:template 
;match="/">
<html>
<head>
<TITLE>moreover
...</TITLE>
</head>
<body BGCOLOR="ffffff">
<DIV ALIGN="
center">
<TABLE BGCOLOR="ffffff" BORDER="0" CELLPADDING="4" CELLSPACING="0" WIDTH="100%">
<xsl:for-
each select="moreovernews/article">
<TR VALIGN="middle">
<TD ALIGN="left" BGCOLOR="ffffff">
<xsl:attribute name="
hrEF">
<xsl:value-of select="url"/>
</xsl:attribute>
<xsl:attribute name="T
argET">
_blank
</xsl:attribute>
<xsl:value-of select="headline_text"/>
<xsl:attribute name="HREF">
<xsl:value-of select="document_url"/>
</xsl:attribute>
<xsl:attribute name="TARGET">
_blank
</xsl:attribute>
<xsl:value-of select="source"/>
<xsl:attribute name="HREF">
<xsl:value-of select="access_registration"/>
</xsl:attribute>
<xsl:attribute name="TARGET">
_blank
</xsl:attribute>
<xsl:value-of select="access_
status"/>
<xsl:value-of select="harvest_time"/> GMT
</TD>
</TR>
</xsl:for-each>
</TABLE>
</DIV>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
脚本宝典总结
以上是脚本宝典为你收集整理的asp下利用XMLHTTP 从其他页面获取数据的代码全部内容,希望文章能够帮你解决asp下利用XMLHTTP 从其他页面获取数据的代码所遇到的问题。
如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。