Results 1 to 9 of 9

Thread: Getting Source of Web Page [Impossible?]

  1. #1

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    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

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    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.

  4. #4
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Getting Source of Web Page [Impossible?]

    I'm not sure, but the following code should work.

    vb.net Code:
    1. Dim wc As New System.Net.WebClient()
    2.         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
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  5. #5

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    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?

  6. #6
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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?
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  7. #7

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: Getting Source of Web Page [Impossible?]

    Quote Originally Posted by stanav View Post
    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

  8. #8
    Member GeekInOhio's Avatar
    Join Date
    Jun 2008
    Location
    You'll never guess...
    Posts
    56

    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:
    1. 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.
    In case I forget: I'm using Visual Basic 2008 Express Edition...

    Should I, in my odd, bumbling way, actually offer some assistance, feel free to show me some RATE love.


    Just Another Laptop Hero

  9. #9
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Getting Source of Web Page [Impossible?]

    Based on that, I'd say...
    vb Code:
    1. Public Function GetHTML(ByVal page As HTMLDOCTYPE) As String()
    2.       Dim totalsource As New List(Of String)
    3.       totalsource.Add(page.DocumentText)
    4.       If page.Frames.Count > 0 Then
    5.             Dim i As Integer = 0
    6.             While i < page.Frames.Count
    7.                   totalsource.AddRange(GetHTML(page.Frames(i)))
    8.                   i += 1
    9.             End While
    10.       End If
    11.       Return totalsource.ToArray()
    12. End Function

    You'll have to iron it out, it's semi-hemi-demi-psuedocode.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width