views:

193

answers:

1

I am trying to do some screen-scraping of a website. The content that I want to get is inside of an IFrame. How do I get the InnerText or HTML that is being displayed inside of the IFrame?

I am using .Net 4.0 and C#. I want to be able to do this from a WinForm.

I tried this, but can't find where to get the actual data from...

    void PageCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        WebBrowser b = sender as WebBrowser;
        string response = b.DocumentText;

        HtmlElement element = b.Document.GetElementById("profileFrame");
        if (element != null)
        {
            // do something with the data
        }
    }

I've tried searching through the element but couldn't find any of the HTML. Is this possible?

+2  A: 

The contents of the iframe isn't included in the first document. You would need to make a second request to the source address of the iframe to get the content displayed in the iframe.

Sohnee