Getting HTML content from IFRAME

StormNet
StormNet used Ask the Experts™
on
Hi all,

I would really appreciate some help in getting a working solution to a little problem I have as I have limited experience in this area.

I would like to be able to extract data from a table contained in an IFrame as well as information.  However, I discovered that there are security restrictions in place that will not allow me to do this.

I know I can right-click on the iframe when the page is loaded and select "View Source" and this will give me the html.  I also know that I can look in my history and get the htm file from there.  

I would like a more elegant solution that I can implement as soon as the main page and its iframes have finished downloading.  I dont have to display the webpage if necessary.  I just need the html behind it.


I would really appreciate some help in this regard.  

I am using VB6 in Microsoft Access.  

Regards
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
To clarify something, Access uses VBA, which has many similarities, but some things don't work exactly the same as VB6.

I have a couple ideas for you.

1. This page (http://www.ozgrid.com/forum/showthread.php?t=91644&page=1) shows someone doing something like what you describe.  This uses Microsoft Internet Controls that you would have to add as a Reference.  In that case, you have to parse the text.

2. I had a similar need, and I wrote a vb6 test harness app that can send and receive HTML and XML content, mainly for web services, but it may work as a starting point for your situation.  I don't see any reason why we couldn't get it to work in Access, since the core functionality is based on Microsoft WinHTTP services.  If you have access to VB6, you can download the project from the article I wrote about it here: http://www.experts-exchange.com/Programming/Languages/Visual_Basic/A_6556-Sending-and-receiving-XML-or-HTML-data-communicating-with-web-services-using-VB6.html.  In this case also you would have to parse the text.

If not, let me know and I'll convert it to Access 2002, if that's ok.  What version of Access are you working in?

3. You could also use the Microsoft Internet Controls reference and add a web browser control to a form and load the contents of the page to it and use DOM to read the contents.  

Those are big picture ideas.  What do you think?

Author

Commented:
Hi kbirecki,

Thanks for coming back to me.  

I wont be able to test the code as I'm out of the office most of the day.  I did have a quick look at it but I'll test it this evening when I get back in.

Regards

Author

Commented:
Hi kbirecki,

Thanks for clarifying the difference between VBA and VB6.  It would explain why some code snippets I tested failed.  Having said that I tested the code here (http://www.ozgrid.com/forum/showthread.php?t=91644&page=1) and it works like a charm!  I have modified it and pointed it to a Webbrowser control and it works perfectly.

My last question relates to this code snippet from the suggestion you gave me.  What is the variable type for s?  In part of my code I apparently need to set "option explicit" and all the variables need to be defined.

                          For i = 0 To appIE.document.getElementsByTagName("TD").Length - 1
                                Set s = appIE.document.getElementsByTagName("TD").Item(i)
                                txt = s.getAttribute("innerText")
                                If txt <> "" Then

Thank you so much for your assistance!  You cant imagine how grateful I am.

Regards

Commented:
Try this (you'll need Microsoft XML added to your references): (Note: I haven't tried this, but I think this is the correct type it would return.)

Dim s as IXMLDOMNode

Open in new window


If that doesn't work, try this generic approach (no additonal reference necessary):

Dim s as object

Open in new window


If that doesn't work (or for convenience), I'd avoid the problem alltogether and rewrite it like this (again, no additional references necessary):

For i = 0 To appIE.document.getElementsByTagName("TD").Length - 1 
    txt = appIE.document.getElementsByTagName("TD").Item(i).getAttribute("innerText") 
    If txt <> "" Then

Open in new window


Let me  know how it goes.

Author

Commented:
Hi kbirecki,

I opted for the third option and all is good...  :)  

I have asked another question if you would like to have a look at it, perhaps?  It deals with copying an image from the cache and saving it to a different location.

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_27244930.html 

I have asked for the question to be moved as I selected the incorrect zone.

Regards

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial