[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1045
  • Last Modified:

How do I access "View Source" through VBS?

In IE you can go View -> Source.

How can I do this through code? Preferrably through a VBS script?

Right now I have

IE.document.body.InnerHTML

this isn't giving me the same results as going View Source on a web page.
0
jgoeders
Asked:
jgoeders
2 Solutions
 
rejoinderCommented:
Have you tried something like this...
wscript.echo GetHtml("http://www.yourdomain.com")
 
Function GetHtml(sURL) 
    Set oHTML = CreateObject("Microsoft.XMLHTTP")
    Set oWeb = CreateObject("InternetExplorer.Application")
    oWeb.navigate (sURL)
    oHTML.open "GET" , sURL, false
    oHTML.send
    GetHtml = oHTML.responseText
End function

Open in new window

0
 
hieloCommented:
>>Right now I have
>>IE.document.body.InnerHTML
>>this isn't giving me the same results as going View Source on a web page.
That's because the browser "cleans" the source code that the server sends and uses the "clean" version to render the page. So programmatically, when accessing the innerHTML property of any element, the browser will give you the clean version only.

If you want the actual "non-clean" version, you will need to request the document again via ajax.
0
 
jgoedersAuthor Commented:
almost. but the XMLHTTP sends another request for the web page.  I need the source of the original request sent by IE.
0
Technology Partners: 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!

 
rejoinderCommented:
How about something in jscript...
http://www.web-source.net/javascript_view_source2.htm
0
 
ChizlCommented:
rejoinder:

In your code, you don't need:
    Set oWeb = CreateObject("InternetExplorer.Application")
    oWeb.navigate (sURL)

However, the rest of it will give you exactly what you see on view source.    Problem is, not everyone has the XMLHTTP object installed.   It's not part of the default with Windows.  You must install MSXML to get it.
0
 
rejoinderCommented:
I don't know if this will help view the code on your page but I spotted this tool today and thought you might want to have a look;
http://technet.microsoft.com/en-us/magazine/cc987541.aspx
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now