Jump to content

lanfong

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by lanfong

  1. Hi all,I would like to ask all of you that is ASP able to get html content from different web page?I know that C# does that. This is how C# works...

    			// Create a request for the URL.		 			WebRequest request = WebRequest.Create ("http://www.google.ca");			// If required by the server, set the credentials.			request.Credentials = CredentialCache.DefaultCredentials;			// Get the response.			HttpWebResponse response = (HttpWebResponse)request.GetResponse ();			// Get the stream containing content returned by the server.			Stream dataStream = response.GetResponseStream ();			// Open the stream using a StreamReader for easy access.			StreamReader reader = new StreamReader (dataStream);			// Read the content.			string responseFromServer = reader.ReadToEnd ();			// Display the content.			Console.WriteLine (responseFromServer);

    the above is the partial code for retrieving content from "http://www.google.ca"I'm just wondering that can ASP do that as well?There's a way i found on the internet but it only works for local server's pages

      <html>	<script>	  var xmlDoc = null;  	  function load() {		if (typeof window.ActiveXObject != 'undefined' ) {		  xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");		  xmlDoc.onreadystatechange = process;		}		else {		  xmlDoc = new XMLHttpRequest();		  xmlDoc.onload = process;		}		xmlDoc.open( "GET", 'register.asp', true );		xmlDoc.send( null );	  }  	  function process() {		if ( xmlDoc.readyState != 4 ) return;		document.getElementById("output").value = xmlDoc.responseText;	  }  	  function empty() {		document.getElementById("output").value = '<empty>';	  }	</script>  	<body>	  <textarea id="output" cols='70' rows='40'><empty></textarea>	  <br></br>	  <button onclick="load()">Load</button>  	  <button onclick="empty()">Clear</button>	</body>  </html>

    if i just change

    		xmlDoc.open( "GET", 'register.asp', true );

    to

    		xmlDoc.open( "GET", http://www.google.ca', true );

    it didn't work. it says... no permission... ?!? no idea... If anyone knows how to do it.. Please help me!! Thank you so much!!!

×
×
  • Create New...