Jump to content

IE.au3 - Reading/Displaying Table Contents


litlmike
 Share

Recommended Posts

Background:

1) I Use IE.au3 a lot for mostly simple routine tasks.

2) I don't know a great deal about HTML, but I am not without hope either.

3) New to using _IETableGetCollection instead of _IETableByIndex

Problem:

1) Whenever coding for a new webpage, I have a hard time determing the table index that I want to work with. Often, I just end up using trial and error until I get the result I am looking for (adding 1 to the index everytime). Up to now, that brute force tactic has worked for me.

Solution:

1) Would like to know a method that will work for most webpages. My ultimate goal is to know how to do this everytime, so I don't have to post questions in the forums, but instead answers.

2) So, if I wanted to get the info in a table I see on a webpage, what is the best way to get that info?

3) It would be nice to display the information of a given Table Index, does anyone have a WYSIWYG? (what you see is what you get)

Example:

For instance, let's take this webpage with 60 different tables:

Example Page

1) Let's say I want to read and display the contents of the gray colored table on the top right. How would I know the table index?

2) Once I determine that, how would I save the following data in the table as $By, $Size, $Price?

By: ProSource Performance

Size: 60 Tablets

Price : $59.95

Thanks In Advance

Link to comment
Share on other sites

a good start, IE.au3 Builder

here....

http://www.autoitscript.com/forum/index.ph...c=19368&hl=

8)

Thanks for the feedback and making a great tool for us. I acutally already use Builder whenever I am using IE.au3. Sometimes when I go to HTML elements I am able to find what am looking for right away, because it is labled. But like in this example, there is nothing distinguishable.

My guess is that there is a process that most of you good programmers use to find your answers efficiently. I would like to know that process.

Thanks again.

Link to comment
Share on other sites

There is no pat answer to this. One way us to View Source. search for <table and count starting at 0 until you find the one you want. You can employ some of the techniques used in IE Builder to automate some of it however.

I'll give you a quick function taht will return table index values based on innerText matches... note that since tables can be nested you will often get multiple matches on the same string and you'll typically use the highest index value.

You can enhance this to do something better than write the indexes of the table to the console...

Func _ShowTableIndexes($oIE, $matchString)
    ; $oIE = browser object, $matchString = text string in table to match
    Local $i = 0
    $oTables = _IETableGetCollection($oIE)
    For $oTable in $oTables
        If StringInStr($oTable.innerText, $matchString) Then
            ConsoleWrite("Match found.  Table Index: " & $i & @CR)
        EndIf
    $i += 1
    Next
EndFunc

Dale

Edit: changed AutoIt 1-2-3 reference to IE Builder

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...