Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)delv
published in(发表于) 2013/12/31 6:40:02
利用XMLHTTP从其他页面获取网页数据_JavaScript技术_编程技术

利用XMLHTTP从其他页面获取网页数据_JavaScript技术_编程技术-你的首页-uuhomepage.com
我们在编写ASP代码的时候,大家都知道可以通过post或者get获得form表单的数据,那么我们如何直接获得其他页面上的数据呢?这就要借助xmlhttp协议了。xmlhttp是xmldom技术的一部分。

下面的代码就是一个很简单的例子,我们利用xmlhttp技术,把http://www.codetoad.com/站点首页的代码以xml的形式完全获取,并且在页面中输出。


<%
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("Microsoft.XMLHTTP")

xml.Open "GET", "http://www.codetoad.com/", False
' Pull the data from the web page
xml.Send
Response.write "Here's the html we now have in our xml object"
Response.write "


"
Response.Write "" <BR> Response.Write xml.responseText <BR> Response.Write ""
Response.write "


"
Response.write " Now here's how the page looks:

"
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%20reviews&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:




moreover...














_blank






_blank






_blank


GMT









If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759