How do I Get The HTML Source of Any Web Page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SwapnilD
    New Member
    • Jan 2010
    • 41

    #1

    How do I Get The HTML Source of Any Web Page

    How can I get the HTML source of any web page.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Firefox: Ctrl + u
    Safari + Chrome: Crtl + Alt + u

    Comment

    • SwapnilD
      New Member
      • Jan 2010
      • 41

      #3
      Sorry, I didn't explain it well.
      I want to get the source code of page dynamically/problematically/through javascript etc.

      below is code I tried to achieve the task but it does not and giving me error "ACCESS DENIED"
      Code:
            <script language=javascript>
      var xmlHttp
       
       function DecodeThisVIN()
       {
        
         url = "www.XYZ.COM"
        
      
       xmlHttp=GetXmlHttpObject();
      
         xmlHttp.open("GET",url,false); //This is the line where I'm getting error
         
      
         var getstatus = xml.status;
         
      
         alert(getstatus);
         
       }
      
      
       function GetXmlHttpObject()
        {
        var xmlHttp=null;
        try
        {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
        catch (e)
        {
        // Internet Explorer
        try
         {
         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
         }
        catch (e)
         {
         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
         }
        }
        return xmlHttp;
        }
      </script>

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        AJAX adheres to the "Same Origin Policy" (SOP), that means, it only fetches data from the same domain (for security reasons).

        Comment

        • SwapnilD
          New Member
          • Jan 2010
          • 41

          #5
          Okay, do you know another way do the above mentioned task?

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            by a server side language.

            Comment

            • SwapnilD
              New Member
              • Jan 2010
              • 41

              #7
              Originally posted by Dormilich
              by a server side language.
              I tried it with asp but still getting error.
              Code:
               Dim xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") 
                  xmlhttp.open ("GET", url, true)
                 xmlhttp.send ("")
                  Response.write (xmlhttp.responseText)
                  xmlhttp = nothing
              Please note for above code xmlHTTP has third parameter as TRUE. In this case I get error "The data necessary to complete this operation is not yet available."

              If I make it "FALSE" then get error "A connection with the server could not be established "

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                this seems to be C# or something similar, where I can’t tell anything about it.

                Comment

                • jkmyoung
                  Recognized Expert Top Contributor
                  • Mar 2006
                  • 2057

                  #9
                  Is there a specific reason you're using ASP? There are any number of simpler alternatives. What languages are you restricted to?

                  Comment

                  Working...