[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

XMLHTTPClass does not always retrieves remote URL data - some sites work - some Don't is there a better way to scrape?

Posted on 2004-11-28
2
Medium Priority
?
425 Views
Last Modified: 2008-01-09
Hi

This works using one remote URL
Http://www.sembel.net

but not a second one www.cnn.com
Will not work with a call to cnn - here's the response.

Not Found The requested URL / was not found on this server.</p>\n<hr />\n<address>Apache Server at www.cnn.com Port 80</address>\n</body></html>\n"

IS there a better way?

CODE--

string postData = "";
string uriString = "http://www.cnn.com";
string strXML ;

XMLHTTPClass xmlHTTP = new XMLHTTPClass();

xmlHTTP.open("POST", uriString,false,null,null) ;
xmlHTTP.send(postData) ;

while(xmlHTTP.readyState != 4)
      {
      }
                  
strXML = (string)xmlHTTP.responseText;

Code--
0
Comment
Question by:paygo
  • 2
2 Comments
 
LVL 31

Accepted Solution

by:
GwynforWeb earned 2000 total points
ID: 12696381
Use this in client side JS

<body onload="init()">
<input value="view Yahoo" type="button" onclick="alert(document.getElementById('yahoo').innerHTML)">
<input value="view ebay"type="button" onclick="alert(document.getElementById('ebay').innerHTML)"> <p>
<script>
function LoadPage(theURL,theID){
   var objSrvHTTP;
    try{
          objSrvHTTP = new ActiveXObject("Msxml2.XMLHTTP.4.0");
         
     }
     catch(e){    
          try{
               objSrvHTTP = new ActiveXObject("Msxml2.XMLHTTP");
          }
               
          catch(e){
               try{              
                    objSrvHTTP = new ActiveXObject("Microsoft.XMLHTTP");
                    alert("ok you have Microsoft.XMLHTTP")
               }                  
               catch(e){              
                    alert("you need install MSXML 4.0, http://www.microsoft.com/downloads/");
                    return;
               }    
          }
     }
       objSrvHTTP.open ("GET",theURL,false);
       objSrvHTTP.send ("");
       document.getElementById(theID).innerHTML=objSrvHTTP.responseText;
}

function init(){
     LoadPage("http://www.yahoo.com","yahoo")
     LoadPage("http://www.ebay.com","ebay")
}
</script>
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 12703299
thanks for the points
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question