Home All Groups Group Topic Archive Search About

WebBrowser1.DocumentText

Author
1 Jul 2006 11:18 PM
nime
How can I grab html source of a frame?

I can retrive main frame by WebBrowser1.DocumentText
but I want to retrive inner (child) frame...

WebBrowser1.Document.Window.Frames(0).DocumentText like thing doesn't exist...

Author
2 Jul 2006 6:04 AM
Cor Ligthert [MVP]
Nime,

You are number three asking this in this newsgroup. In my idea you cannot do
that with the new webbrowser (it is missing downloadcomplete). You can do it
with the Axwebbrowser. If you only want to get one special frame with its
own URL, than you can as well use this

http://www.vb-tips.com/dbPages.aspx?ID=541adf13-d9c0-435c-893f-56dbb63fdf1c

I hope this helps,

Cor




Show quoteHide quote
"nime" <ea2***@planev.com> schreef in bericht
news:eUqN4SWnGHA.1584@TK2MSFTNGP02.phx.gbl...
> How can I grab html source of a frame?
>
> I can retrive main frame by WebBrowser1.DocumentText
> but I want to retrive inner (child) frame...
>
> WebBrowser1.Document.Window.Frames(0).DocumentText like thing doesn't
> exist...
>
>
>
>
>
Author
2 Jul 2006 12:37 PM
Herfried K. Wagner [MVP]
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
> You are number three asking this in this newsgroup. In my idea you cannot
> do that with the new webbrowser (it is missing downloadcomplete).

What about this solution?

\\\
Private Sub WebBrowser1_DocumentCompleted( _
    ByVal sender As Object, _
    ByVal e As WebBrowserDocumentCompletedEventArgs _
) Handles WebBrowser1.DocumentCompleted
    If Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
        MsgBox("Document and frames loaded!")
    End If
End Sub
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
2 Jul 2006 12:40 PM
nime
This event never fired here : (

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:%23cSGVRdnGHA.2148@TK2MSFTNGP03.phx.gbl...
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
>> You are number three asking this in this newsgroup. In my idea you cannot do that with the new webbrowser (it is missing
>> downloadcomplete).
>
> What about this solution?
>
> \\\
> Private Sub WebBrowser1_DocumentCompleted( _
>    ByVal sender As Object, _
>    ByVal e As WebBrowserDocumentCompletedEventArgs _
> ) Handles WebBrowser1.DocumentCompleted
>    If Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
>        MsgBox("Document and frames loaded!")
>    End If
> End Sub
> ///
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
2 Jul 2006 12:52 PM
Cor Ligthert [MVP]
Herfried,

Did you try it, if it works than it is a great one?

:-)

Cor

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:%23cSGVRdnGHA.2148@TK2MSFTNGP03.phx.gbl...
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
>> You are number three asking this in this newsgroup. In my idea you cannot
>> do that with the new webbrowser (it is missing downloadcomplete).
>
> What about this solution?
>
> \\\
> Private Sub WebBrowser1_DocumentCompleted( _
>    ByVal sender As Object, _
>    ByVal e As WebBrowserDocumentCompletedEventArgs _
> ) Handles WebBrowser1.DocumentCompleted
>    If Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
>        MsgBox("Document and frames loaded!")
>    End If
> End Sub
> ///
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
2 Jul 2006 1:06 PM
Herfried K. Wagner [MVP]
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
> Did you try it, if it works than it is a great one?

Yes, it worked for the framesets I tested on the Web, but I am not sure if
it will still work if one of the frames contains a media stream or similar
that is still loading after the actual /documents/ have been loaded.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
3 Jul 2006 8:46 PM
Cor Ligthert [MVP]
Herfried,

I can not reach you by mail. Can I use this in documentation (by instance
our website?)

Cor

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:uqRZbhdnGHA.4728@TK2MSFTNGP03.phx.gbl...
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
>> Did you try it, if it works than it is a great one?
>
> Yes, it worked for the framesets I tested on the Web, but I am not sure if
> it will still work if one of the frames contains a media stream or similar
> that is still loading after the actual /documents/ have been loaded.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
3 Jul 2006 8:50 PM
Herfried K. Wagner [MVP]
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
> I can not reach you by mail.

Sorry, unfortunately I was too busy to answer emails :-(.

> Can I use this in documentation (by instance
> our website?)

Yes, you can use it, but I suggest to test the solution extensively.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
2 Jul 2006 12:38 PM
nime
Thank you for your valuable responses.

I am currently using WebBrowser control to automate a few things like auto-login a site, etc.


I don't know what is the difference between Navigated and DocumentComplete events, plus
in my application, DocumentComplete event never fired yet... Then I used Navigated instead.
But the problem is that the document is incomplete. I've examined Document.body.innerHTML
and only a part of the source appears...

Private Sub WebBrowser1_Navigated(...)

        Select Case e.Url.ToString

            Case "http://www.domain.com/"

                    ''''ProcessMainPage() ' Do nothing

            Case "http://www.domain.com/login.asp" 'Login frame

                ProcessLoginPage()

        End Select

End Sub

Private Sub ProcessLoginPage()

    Dim frm as HTMLDocument
    Dim el as HTMLElement

    For i = 0 To WebBrowser1.Document.Window.Frames.Count - 1

        'Find the login frame
        If WebBrowser1.Document.Window.Frames(i).Document.Window.Url.ToString = "http://www.domain.com/login.asp" Then
            frm = WebBrowser1.Document.Window.Frames(i).Document

            'Fill the form
            For Each el In frm.Forms
                        Select Case el.Name
                            Case "login"
                                el.InnerText = "username"
                            Case "pass"
                                el.InnerText = "secret"
                        End Select
            Next el



        End If

    Next i

End Sub
Author
2 Jul 2006 9:03 AM
gene kelley
On Sun, 2 Jul 2006 02:18:48 +0300, "nime" <ea2***@planev.com> wrote:

>How can I grab html source of a frame?
>
>I can retrive main frame by WebBrowser1.DocumentText
>but I want to retrive inner (child) frame...
>
>WebBrowser1.Document.Window.Frames(0).DocumentText like thing doesn't exist...
>
>
>
>
See if this helps:

Private LinksTable As Hashtable

Private Sub WebBrowser1_DocumentCompleted(ByVal _
     sender As Object, ByVal e As _
     System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) _
     Handles WebBrowser1.DocumentCompleted

      GetLinksFromFrames()

End Sub

    Private Sub GetLinksFromFrames()
        LinksTable = New Hashtable()
        Dim FrameUrl As String

        If (Not WebBrowser1.Document Is Nothing) Then
            With WebBrowser1.Document
                Dim CurrentWindow As HtmlWindow = .Window
                If (CurrentWindow.Frames.Count > 0) Then
                    For Each Frame As HtmlWindow In _
             Frame.Document.Links
                        FrameUrl = Frame.Url.ToString()

                        Dim ThisFrameName As String = Frame.Name
                        Dim ThisFrameDocument As _
                           HtmlDocument = Frame.Document

                        Dim FrameLinksHash As New Hashtable()
                        LinksTable.Add(FrameUrl, FrameLinksHash)

                        For Each HrefElement As HtmlElement In _     
        Frame.Document.Links
                         FrameLinksHash.Add(HrefElement.GetAttribute _
                            ("HREF"), "Url")
                        Next
                    Next
                Else
                    Dim DocLinksHash As New Hashtable()
                    LinksTable.Add(.Url.ToString(), DocLinksHash)

                    For Each HrefElement As HtmlElement In .Links
                      DocLinksHash.Add(HrefElement.GetAttribute _
                        ("HREF"), "Url")
                    Next
                End If
            End With
        End If
    End Sub


Gene
Author
2 Jul 2006 12:32 PM
Herfried K. Wagner [MVP]
"nime" <ea2***@planev.com> schrieb:
> How can I grab html source of a frame?
>
> I can retrive main frame by WebBrowser1.DocumentText
> but I want to retrive inner (child) frame...
>
> WebBrowser1.Document.Window.Frames(0).DocumentText like thing doesn't
> exist...

\\\
For Each Frame As HtmlWindow In Me.WebBrowser1.Document.Window.Frames
    MsgBox(Frame.Document.All(1).OuterHtml)
Next Frame
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
2 Jul 2006 1:17 PM
nime
Document.Body.outerHTML gets reformatted / non-original
and INCOMPLETE html code. Looks like buggy : (




Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:eDJSkOdnGHA.2264@TK2MSFTNGP04.phx.gbl...
> "nime" <ea2***@planev.com> schrieb:
>> How can I grab html source of a frame?
>>
>> I can retrive main frame by WebBrowser1.DocumentText
>> but I want to retrive inner (child) frame...
>>
>> WebBrowser1.Document.Window.Frames(0).DocumentText like thing doesn't exist...
>
> \\\
> For Each Frame As HtmlWindow In Me.WebBrowser1.Document.Window.Frames
>    MsgBox(Frame.Document.All(1).OuterHtml)
> Next Frame
> ///
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
2 Jul 2006 3:20 PM
Cor Ligthert [MVP]
"> Document.Body.outerHTML gets reformatted / non-original
> and INCOMPLETE html code. Looks like buggy : (
>
No it gives complete HTML code however not always everything on a page.

Cor
Author
2 Jul 2006 4:09 PM
nime
I mean webbrowser1.document.body.innerHTML has a bug here

innerHTML contains no form and I cannot fill the fields....

I've checked url, and compared the html code. Webbrowser1
reformats the tags and removes many lines. I call it as bug,
my form has been cropped : (

Then I tried Mozilla control, it has no problem, it parses everything
with no loss, but I couldn't use it, for example document.all.count
had an error...




Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:%23YPiSrenGHA.4572@TK2MSFTNGP05.phx.gbl...
>
> "> Document.Body.outerHTML gets reformatted / non-original
>> and INCOMPLETE html code. Looks like buggy : (
>>
> No it gives complete HTML code however not always everything on a page.
>
> Cor
>
Author
2 Jul 2006 4:20 PM
Herfried K. Wagner [MVP]
"nime" <ea2***@planev.com> schrieb:
>I mean webbrowser1.document.body.innerHTML has a bug here
>
> innerHTML contains no form and I cannot fill the fields....
>
> I've checked url, and compared the html code. Webbrowser1
> reformats the tags and removes many lines. I call it as bug,
> my form has been cropped : (

Maybe HTML Internet Explorer doesn't understand gets stripped from the
output and the result is simply the serialized part of the DOM tree.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
2 Jul 2006 4:27 PM
nime
But the browser's itself displays the form  in my app ???

I've got another problem with Mozilla control. I cannot fill the form fields which they exist.

    AxMozillaBrowser1.Document.All.Item("login").Value = "xx"

line causes this error:

    A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll


Private Sub AxMozillaBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As
AxMOZILLACONTROLLib.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxMozillaBrowser1.DocumentComplete

        If e.uRL.ToString = "http://www.domain.com/login.asp" Then
            AxMozillaBrowser1.Document.All.Item("login").Value = "xx"
            AxMozillaBrowser1.Document.All.Item("pass").Value = "xxx"

        End If

    End Sub

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:uKLqzNfnGHA.3896@TK2MSFTNGP05.phx.gbl...
> "nime" <ea2***@planev.com> schrieb:
>>I mean webbrowser1.document.body.innerHTML has a bug here
>>
>> innerHTML contains no form and I cannot fill the fields....
>>
>> I've checked url, and compared the html code. Webbrowser1
>> reformats the tags and removes many lines. I call it as bug,
>> my form has been cropped : (
>
> Maybe HTML Internet Explorer doesn't understand gets stripped from the output and the result is simply the serialized part of the
> DOM tree.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
3 Jul 2006 9:40 AM
nime
1. Mozilla Activex control doesn't support all of
properties/methods/elements/etc.

2. IE WebBrowser control did not fire because I've blocked a few IP's
(via hosts file) and an ad related inner frame couldnt complete. So
WebBrowser1_DocumentComplete event did not fire. Now
I did unblock the IPs and event has been called again.

3. Now I have a new problem. Can you please read the topic:
WebBrowser: Programmaticaly click an image button ?

Thank you.



"nime" <ea2***@planev.com>, haber iletisinde þunlarý
yazdý:u1HK8RfnGHA.2***@TK2MSFTNGP03.phx.gbl...
Show quoteHide quote
> But the browser's itself displays the form  in my app ???
>
> I've got another problem with Mozilla control. I cannot fill the form
> fields which they exist.
>
>    AxMozillaBrowser1.Document.All.Item("login").Value = "xx"
>
> line causes this error:
>
>    A first chance exception of type
> 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
>
>
> Private Sub AxMozillaBrowser1_DocumentComplete(ByVal sender As Object,
> ByVal e As AxMOZILLACONTROLLib.DWebBrowserEvents2_DocumentCompleteEvent)
> Handles AxMozillaBrowser1.DocumentComplete
>
>        If e.uRL.ToString = "http://www.domain.com/login.asp" Then
>            AxMozillaBrowser1.Document.All.Item("login").Value = "xx"
>            AxMozillaBrowser1.Document.All.Item("pass").Value = "xxx"
>
>        End If
>
>    End Sub
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> news:uKLqzNfnGHA.3896@TK2MSFTNGP05.phx.gbl...
>> "nime" <ea2***@planev.com> schrieb:
>>>I mean webbrowser1.document.body.innerHTML has a bug here
>>>
>>> innerHTML contains no form and I cannot fill the fields....
>>>
>>> I've checked url, and compared the html code. Webbrowser1
>>> reformats the tags and removes many lines. I call it as bug,
>>> my form has been cropped : (
>>
>> Maybe HTML Internet Explorer doesn't understand gets stripped from the
>> output and the result is simply the serialized part of the DOM tree.
>>
>> --
>> M S   Herfried K. Wagner
>> M V P  <URL:http://dotnet.mvps.org/>
>> V B   <URL:http://classicvb.org/petition/>
>
>