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.
LVL 2
jgoedersAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.