g5mike Posted June 17, 2005 Share Posted June 17, 2005 I've tralled this forum and msdn and I'm trying to find away to access table element data - any ideas? Using the beta version and COM to IE. Link to comment Share on other sites More sharing options...
scriptkitty Posted June 17, 2005 Share Posted June 17, 2005 Table elements are a bit tough to use as elements without a custom UDF.There was one made to parse out table elements in scraps a long time ago, but I am not sure if it would even be helpful, after all the customizations you would have to do.First off, you can use the new obj/com to get the part of the web page you want (full, form,etc.)Next, you will have to look at the HTML, and do your parsing.You could make up an array with all the table elements. I use elements very loosely, and actually I don't think HTML tables have elements. (elements=links,form parts, images, etc)A new table part will start with <td or <tr If you wanted an array, you could do it mickeymouse style via something like this:$array=stringreplace($HTML,"<td",)$array=stringreplace($array,"<tr",)$array=stringsplit($array,)then you can remove a bit of the formatting, because many parts will look like this:>start of table stuff</td>orcolspan=2 width="203" hieght=30%>more table stuff</tr>You basically have to understand HTML to do this quickly. If not, maybe you can look for that HTML Table UDF and dump the HTML from the page in, and hook up a little search.Frames, and IFrames are a quite different animal. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
g5mike Posted June 17, 2005 Author Share Posted June 17, 2005 cheers scriptkitty, I'll probably search/parse the HTML myself. From looking at how to access form elements i thought it may have been 'that' easy. Thanks for your help! - read some of your previous posts about IE too - very helpful. Link to comment Share on other sites More sharing options...
DaleHohm Posted June 18, 2005 Share Posted June 18, 2005 I've tralled this forum and msdn and I'm trying to find away to access table element data - any ideas? Using the beta version and COM to IE.<{POST_SNAPBACK}>The DOM doesn't have a TABLE collection in the same way that it has, for example, a FORM collection -- however, there is another way to attack it.getElementsByTagName(tag) will create a collection of all elements of that tag. .innerHTML will allow you to retrieve the contents of that tag.Here are a couple of sites with a bunch of Javascript examples and I'll include a couple of au3 examples below.HTML DOM Table ObjectTraversing an HTML table with Javascript and DOM InterfacesThis example parses the each table on the page and writes the contents of each TD element to the console:$ObjIE=ObjCreate("InternetExplorer.Application") With $ObjIE .Visible = True .Navigate("http://www.autoitscript.com/") while .ReadyState <> 4 Sleep(50) wend EndWith $document = $objIE.document $body = $document.getElementsByTagName("body").item(0) $tables = $body.getElementsByTagName("table") For $table in $tables $rows = $table.getElementsByTagName("tr") For $row in $rows $tds = $row.getElementsByTagName("td") For $td in $tds ; Display the HTML contents of each cell... ConsoleWrite($td.innerHTML) Next Next Next ExitThis example is nearly the same, but it only parses the first table in the document:$document = $objIE.document $body = $document.getElementsByTagName("body").item(0) $table = $body.getElementsByTagName("table").item(0) $rows = $table.getElementsByTagName("tr") For $row in $rows $tds = $row.getElementsByTagName("td") For $td in $tds ; Display the HTML contents of each cell... ConsoleWrite($td.innerHTML) Next Next ExitThere are lots of possibilities here...Dale 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 More sharing options...
g5mike Posted June 18, 2005 Author Share Posted June 18, 2005 Wow, cool thanks! Gonna have a play with that, pretty powerful cheers again! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now