lanfong Posted September 20, 2006 Share Posted September 20, 2006 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!!! Link to comment Share on other sites More sharing options...
aspnetguy Posted September 20, 2006 Share Posted September 20, 2006 try this http://www.codetoad.com/asp_http_cache.asp Link to comment Share on other sites More sharing options...
justsomeguy Posted September 20, 2006 Share Posted September 20, 2006 You might also try changing the third parameter of XMLHttpRequest.open to false instead of true to make the request synchronous instead of asynchronous. That will make the application wait until the response comes back before it moves on.More info here:http://www.15seconds.com/issue/020606.htm Link to comment Share on other sites More sharing options...
lanfong Posted September 21, 2006 Author Share Posted September 21, 2006 thanks for telling me those useful information.I will try your suggestions tonight!!!Thanks a lot Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now