Get Web page data from other pages using XMLHTTP

Source: Internet
Author: User
Tags xsl
xml| Data | page | page when we write the ASP code, we all know that we can get the data of form forms by post or getting, so how do we get the data directly from other pages? This is going to be through the XMLHTTP agreement. XMLHTTP is part of the XMLDOM technology.

The following code is a very simple example, we use the XMLHTTP technology, the http://www.codetoad.com/site first page of the code in the form of XML fully obtained, and output in the page.

<%
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 "<BR><BR><BR>"
Response.Write "<xmp>"
Response.Write Xml.responsetext
Response.Write "</xmp>"
Response.Write "<BR><BR><BR>"
Response.Write "Here's how the page looks:<br><br>"
Response.Write Xml.responsetext

Set xml = Nothing
%>

Here is another example
<%
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:
<xsl:stylesheet xmlns:xsl= "Http://www.w3.org/TR/WD-xsl" >
<xsl:template match= "/" >
<TITLE>moreover...</TITLE>
<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" >
&LT;TD align= "left" bgcolor= "FFFFFF" >
<xsl:attribute name= "HREF" >
<xsl:value-of select= "url"/>
</xsl:attribute>
<xsl:attribute name= "TARGET" >
_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>
</xsl:template>
</xsl:stylesheet>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.