Getting Source of Web Page [Impossible?]
I need to get the source of a webpage that my browser control has loaded.
Whenever i use browser.document.htmltext or anything like that dont get the proper source that i need.
The URL is masked so i can't use some sort of HTTP response request to get the page source.
The website only works with IE and does not behave normally like most sites.
The only way I've been able to get the source that i need is right clicking the webpage in my browser, and selecting "View Source".
How can i do this "View Source" programmicatally so i can work with the source code of the web page?
Thanks,
Philly0494
Re: Getting Source of Web Page [Impossible?]
What you need is the DocumentText property of the WB object.
Code:
Dim htmlSource As String = browser.DocumentText
Note that if the page uses frames, you will only get the source of 1 frame.
Re: Getting Source of Web Page [Impossible?]
i guess i wasn't clear, the webpage is in frames and .DocumentText does not supply the source code that I need
i have tried almost everything but I am still unable to retrieve the source of this web page.
The URL is static regardless of where you navigate to on this website.
Re: Getting Source of Web Page [Impossible?]
I'm not sure, but the following code should work.
vb.net Code:
Dim wc As New System.Net.WebClient()
TextBox1.Text = wc.DownloadString("http://google.com")
If it doesn't work, what website's html are you trying to obtain?
*Edit- This won't apply. I didn't read the post entirely :P Sorry
Re: Getting Source of Web Page [Impossible?]
yeah that won't work cause the URL i static throughout navigation of the site
so is there any way to do this?
Re: Getting Source of Web Page [Impossible?]
Why don't you give us the url of that web page so that we can try to work it out?
Re: Getting Source of Web Page [Impossible?]
Quote:
Originally Posted by
stanav
Why don't you give us the url of that web page so that we can try to work it out?
the URL is: https://navinet.navimedix.com/Main.asp
but you have to login to navigate to the page that I need, but the URL remains the same even after you login and navigate through the site
Re: Getting Source of Web Page [Impossible?]
I do a rather insane amount of work with the WebBrowser control. This should work for you:
vb Code:
MsgBox(Me.WebBrowser1.Document.Window.Frames(6).Frames(1).Document.All(1).OuterHtml)
Note that in that example I am accessing a frame nested inside of another set of frames. Once you know where the frame is located, that is how you access it's source.
Hope it helps.
Re: Getting Source of Web Page [Impossible?]
Based on that, I'd say...
vb Code:
Public Function GetHTML(ByVal page As HTMLDOCTYPE) As String()
Dim totalsource As New List(Of String)
totalsource.Add(page.DocumentText)
If page.Frames.Count > 0 Then
Dim i As Integer = 0
While i < page.Frames.Count
totalsource.AddRange(GetHTML(page.Frames(i)))
i += 1
End While
End If
Return totalsource.ToArray()
End Function
You'll have to iron it out, it's semi-hemi-demi-psuedocode.