-
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.
-
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
>
>
-
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
-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks