Results 1 to 5 of 5

Thread: [2008] HTML Content from a Frame

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    36

    [2008] HTML Content from a Frame

    Hi,

    I have read many posts on this - from here and other sites - but I don't have an answer that resolves my problem.

    I want to read the HTML from a frame in a web page. I have started with a WebBrowser, which I browse through manually, attempting to scrape the details as I go. The reasn for using Web Browser is that it involves a complex form, which I can't really replicate in code.

    If I directly query the WebBrowser info I get very little, and the frame data id represented simply by a FRAME TAG, and a simple URI with no form data (it needs the data to return the content)

    I tried the Web Browser documentStream, and again I get very little.

    The closest I got to the full HTML is the following code. However it is missing the OBJECT tag and it's contents, which is what I absolutely need:

    Code:
            htmlwin = wb.Document.Window
            For Each frame As HtmlWindow In htmlwin.Frames
                For Each el In frame.Document.All
                    If el.InnerHtml <> Nothing Then lb1.Items.Add(el.InnerHtml)
                    addLevel(el)
                    num += 1
                Next
                docFrame(frame)
            Next
    The AddLevel() iterates through the numerous element levels.

    The raw HTML (as in "View Source" from Internet Explorer) would be perfect. I can't find a method to simply retrieve this.

    Can anyone help me progress this? Many thanks in advance.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2008] HTML Content from a Frame

    You can check out this code:
    http://www.vbforums.com/showthread.php?t=416275

    One thing you need to remember, is when you are on a frames page, clicking the "view source" in IE gives you the source for the frame you were actually moused over at the time. So in code, you need to grab the specific frame you want, and then just grab the HTML source from that.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    36

    Re: [2008] HTML Content from a Frame

    Thanks Kleinma, I actually have that source already. It has given me a good head-start with everything but the frames!

    I understand the right-click and View Source now. I was on the internet when it was born, how could I possibly have missed that one!

    So, I still have a problem. Here's the main document (with the URL removed, it's an intranet). I've removed some superfluous content too - long scripts etc.

    Code:
    <html>
    <head>
    <style TYPE="text/css" MEDIA="screen"><!-- @import url("mysite.com/Classes.css"); -->
    <!-- @import url(""); --></style>
    
    <script language=JavaScript>function TestValidation() {
    // Long JavaScript goes here</script>
    
    
    <title>Home</title>
    </head>
     
    <frameset name="mainframe" rows="103,*" border=0 frameborder="0">
      <frame frameborder=0 scrolling=no name="contents" target="main" src="http://mySite.com/MyPage/menu.asp" noresize >
      <frame frameborder=0 name="main" src="http://mySite.com/MyPage//main.asp">
    </frameset>
    <body scroll="no" bgcolor="#FFFFFF">
    </body>
    </html>
    One thing I notice is that the frames are not in the body element - does that matter? My code does not reference the Body property, only the document. It also seems to pick up on the frames but not all of the frame content.

    One thing I wanted to do was make a documentStream from the frames, as this worked well at a higher level. But I don't see a way of getting a stream from html.window.frames.

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2008] HTML Content from a Frame

    What if you try something like this?

    Code:
            For Each Window As HtmlWindow In WebBrowser1.Document.Window.Frames
                MessageBox.Show(Window.Document.Body.OuterHtml)
            Next

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    36

    Re: [2008] HTML Content from a Frame

    I have resolved my current problem, your last post triggered a thought. It's good old User Error - I was reaching the frame, then reading the data from the parent of the frame. I can see from your last suggestion that I had not drilled far enough down through the properties of the frame.

    Thanks again!

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