nasty Posted July 11, 2013 Share Posted July 11, 2013 (edited) Please i need help. I have a page and i need to extract all the onlick's links inside X <tr> and put in an array. These tr's have only alternating 2 types of class and NO NAME. I have tried several methods without success .. Please anyone can help? What _IE functions is adapt for this problem? I put an example: expandcollapse popup<table id="rounded-corner" summary="List" border="1" cellpadding="0" cellspacing="0"> <tr class="r1 link highlight" title="" onclick="location.href='link.aspx?codeid=0111'"> <td> INFO </td> <td title="INFO">INFO ...</td> <td>11/07/2013</td> <td>11/07/2013</td> <td title="INFO2">INFO2</td> <td style="text-align:center"><font color='Green'><b>6</b></font></td> <td style="text-align:center" title="Normal"><img src='2.gif'/></td> </tr> <tr class="r2 link highlight" title="" onclick="location.href='link.aspx?codeid=0112'"> <td> INFO </td> <td title="INFO">INFO ...</td> <td>11/07/2013</td> <td>11/07/2013</td> <td title="INFO2">INFO2</td> <td style="text-align:center"><font color='Green'><b>6</b></font></td> <td style="text-align:center" title="Normal"><img src='2.gif'/></td> </tr> <tr class="r1 link highlight" title="" onclick="location.href='link.aspx?codeid=0113'"> <td> INFO </td> <td title="INFO">INFO ...</td> <td>11/07/2013</td> <td>11/07/2013</td> <td title="INFO2">INFO2</td> <td style="text-align:center"><font color='Green'><b>6</b></font></td> <td style="text-align:center" title="Normal"><img src='2.gif'/></td> </tr> <tr class="r2 link highlight" title="" onclick="location.href='link.aspx?codeid=0114'"> <td> INFO </td> <td title="INFO">INFO ...</td> <td>11/07/2013</td> <td>11/07/2013</td> <td title="INFO2">INFO2</td> <td style="text-align:center"><font color='Green'><b>6</b></font></td> <td style="text-align:center" title="Normal"><img src='2.gif'/></td> </tr> </table> so i need to extract from that example code: $array = ('link.aspx?codeid=0111','link.aspx?codeid=0112','link.aspx?codeid=0113','link.aspx?codeid=0114') Please help! Thanks! Edited July 11, 2013 by nasty Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 11, 2013 Moderators Share Posted July 11, 2013 #include <IE.au3> $sURL = "" $sTableId = "rounded-corner" _IEErrorHandlerRegister() $oIE = _IECreate($sURL) ; get reference to the table by id $oTable = _IEGetObjById($oIE, $sTableId) ; get a collection of all table rows $oTableRows = _IETagNameGetCollection($oTable, "TR") ; enumerate through the collection For $oTableRow In $oTableRows ; get the value of the onclick attribute $sOnClickValue = $oTableRow.getAttribute("onclick") ConsoleWrite($sOnClickValue & @CRLF) Next 0xdefea7 1 Link to comment Share on other sites More sharing options...
nasty Posted July 11, 2013 Author Share Posted July 11, 2013 Thanks a lot big:daddy for help!!!! Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 12, 2013 Moderators Share Posted July 12, 2013 The previous code I posted fails to return the attribute on some pages. The following works instead: #include <IE.au3> $sURL = "" $sTableId = "rounded-corner" _IEErrorHandlerRegister() $oIE = _IECreate($sURL, 1) ; get reference to the table by id $oTable = _IEGetObjById($oIE, $sTableId) ; get reference to the table body $oTableBody = _IETagNameGetCollection($oTable, "TBODY", 0) ; get a collection of all rows in the table body $oTableRows = _IETagNameGetCollection($oTableBody, "TR") ; enumerate through the collection For $oTableRow In $oTableRows ; get a collection of attributes for the current table row $oAttributes = $oTableRow.attributes ; enumerate through the collection For $oAttribute In $oAttributes ; search for the onclick attribute If String($oAttribute.name) = "onclick" Then ; return the value of found attribute ConsoleWrite($oAttribute.value & @CRLF) EndIf Next Next Link to comment Share on other sites More sharing options...
nasty Posted July 12, 2013 Author Share Posted July 12, 2013 Thanks again big_daddy ... now is perfect!! Thanks!! 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