View Source


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: View Source

  1. #1
    Steve Guest

    View Source


    Is there a call that I can use that is equivalent to doing the following on
    Internet Explorer?

    View -> Source

    I need access the the HTML programatically.

    Thanks in advanced for any advice.

  2. #2
    Guest

    Re: View Source


    I am not displaying it at all. I need to process some of the HTML code. So,
    I need a way to access the HTML Source.

    "Phil Weber" <pweber@nospam.fawcette.com> wrote:
    > > I need access the the HTML programatically.

    >
    >Steve: In what context? Are you displaying the page in a WebBrowser control,
    >or in the user's browser, or not displaying it at all?
    >---
    >Phil Weber
    >
    >



  3. #3
    Phil Weber Guest

    Re: View Source

    > I need access the the HTML programatically.

    Steve: In what context? Are you displaying the page in a WebBrowser control,
    or in the user's browser, or not displaying it at all?
    ---
    Phil Weber



  4. #4
    James Barbetti Guest

    Re: View Source


    Hi Steve.

    You asked, more or less:
    >Is there a call that I can use that is equivalent to doing a
    >"View Source" on Internet Explorer, programmatically?


    There are several different ways to get that. I'll list the ones that should
    work with an "out of the box" copy of VB6 here.

    Method #1
    =========

    If you are using a WebBrowser control ("Microsoft Internet Controls" component
    must be included in the project), and the document has loaded (e.g. DocumentComplete
    event), you can access the document object model to get the source code of
    the <BODY> part of the page.

    Debug.Print WebBrowser1.Document.body.innerHTML

    If you want to use the document object model itself, that is also possible.
    Add a reference to "Microsoft HTML Object Library" to your project, and
    you could have something like this:

    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object _
    , URL As Variant)
    Dim doc As HTMLDocument
    Set doc = WebBrowser1.Document
    Debug.Print doc.body.innerHTML
    Debug.Print "count of links from page = " _
    & doc.links.length
    End Sub

    Have a play with the HTMLDocument object via intellisense to get a better
    feel for what you can get to. Upside: you can use the document object model
    to narrow down your search. Downsides: you can't see code in the <HEAD>
    part of a page, and it's restricted to HTML documents.

    Method#2
    ========
    Via an instance (inet1) of the "Microsoft Internet Transfer Control",
    you can go:

    Debug.Print Inet1.OpenURL("http://www.devx.com")

    to print the "source code" of a web page, including the HTML and HEAD tags
    (and other stuff outside the BODY). This will show the source of the page
    *before* any javascript in it would be executed by Internet Explorer. It
    will also work okay for URLs other than HTML documents.

    Hope one of these provides what you are after.
    Seeya,
    James

  5. #5
    Steve Guest

    Re: View Source


    This is what I needed. Thanks James!!!

    "James Barbetti" <james_barbetti@yahoo.com> wrote:
    >
    >Hi Steve.
    >
    >You asked, more or less:
    >>Is there a call that I can use that is equivalent to doing a
    >>"View Source" on Internet Explorer, programmatically?

    >
    >There are several different ways to get that. I'll list the ones that should
    >work with an "out of the box" copy of VB6 here.
    >
    >Method #1
    >=========
    >
    >If you are using a WebBrowser control ("Microsoft Internet Controls" component
    >must be included in the project), and the document has loaded (e.g. DocumentComplete
    >event), you can access the document object model to get the source code

    of
    >the <BODY> part of the page.
    >
    >Debug.Print WebBrowser1.Document.body.innerHTML
    >
    >If you want to use the document object model itself, that is also possible.
    > Add a reference to "Microsoft HTML Object Library" to your project, and
    >you could have something like this:
    >
    >Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object _
    > , URL As Variant)
    > Dim doc As HTMLDocument
    > Set doc = WebBrowser1.Document
    > Debug.Print doc.body.innerHTML
    > Debug.Print "count of links from page = " _
    > & doc.links.length
    >End Sub
    >
    >Have a play with the HTMLDocument object via intellisense to get a better
    >feel for what you can get to. Upside: you can use the document object model
    >to narrow down your search. Downsides: you can't see code in the <HEAD>
    >part of a page, and it's restricted to HTML documents.
    >
    >Method#2
    >========
    >Via an instance (inet1) of the "Microsoft Internet Transfer Control",
    >you can go:
    >
    >Debug.Print Inet1.OpenURL("http://www.devx.com")
    >
    >to print the "source code" of a web page, including the HTML and HEAD tags
    >(and other stuff outside the BODY). This will show the source of the page
    >*before* any javascript in it would be executed by Internet Explorer. It
    >will also work okay for URLs other than HTML documents.
    >
    >Hope one of these provides what you are after.
    >Seeya,
    >James



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center