Jump to content

Recommended Posts

Posted

Is there any method for collection com object which define which exact object you want to retreive? I tried use ".index()" method but it didn't worked.

Let me explain my problem with code sample:

Local $aTbodys[0][7]
$oTbodys = _IETagnameGetCollection($oIE, "tbody")
for $oTbody In $oTbodys
    $date = _IETagnameGetCollection($oTbodys, "div", 2).innerhtml
    $name = _IETagnameGetCollection($oTbody, "div", 3).innerhtml
    $surname = _IETagnameGetCollection($oTbody, "div", 4).innerhtml
    $title = _IETagnameGetCollection($oTbody, "div", 5).innerhtml
    $comment1 = _IETagnameGetCollection($oTbody, "div", 6).innerhtml
    $comment2 = _IETagnameGetCollection($oTbody, "div", 7).innerhtml
    $comment3 = _IETagnameGetCollection($oTbody, "div", 8).innerhtml
    _ArrayAdd($aTbodys,  $date & "|" &  $name & "|" &  $surname & "|" &  $title & "|" & $comment1 & "|" & $comment2 & "|" & $comment3)
next
_ArrayDisplay($aTbodys)

I want to optimize speed of processing the data and I belive, that it could be done by replacing multiple used _IETagnameGetCollection() function with only one

Local $aTbodys[0][7]
$oTbodys = _IETagnameGetCollection($oIE, "tbody")
for $oTbody In $oTbodys
    $oDivs = _IETagnameGetCollection($oTbodys, "div")
    
    $date = $oDivs.index(2).innerhtml
    $name = $oDivs.index(3).innerhtml
    $surname = $oDivs.index(4).innerhtml
    $title = $oDivs.index(5).innerhtml
    $comment1 = $oDivs.index(6).innerhtml
    $comment2 = $oDivs.index(7).innerhtml
    $comment3 = $oDivs.index(8).innerhtml
    _ArrayAdd($aTbodys,  $date & "|" &  $name & "|" &  $surname & "|" &  $title & "|" & $comment1 & "|" & $comment2 & "|" & $comment3)
next
_ArrayDisplay($aTbodys)

Above code does not work. It only shows my conception.

Of course I can add each object to array and use array index to get what I need but it does not optimize the speed.

Any idea?

Posted

You mean like:

Local $aTbodys[0][7]
$oTbodys = _IETagnameGetCollection($oIE, "tbody")
for $oTbody In $oTbodys
    $oDivs = _IETagnameGetCollection($oTbodys, "div")
    
    $date = $oDivs(2).innerhtml
    $name = $oDivs(3).innerhtml
    $surname = $oDivs(4).innerhtml
    $title = $oDivs(5).innerhtml
    $comment1 = $oDivs(6).innerhtml
    $comment2 = $oDivs(7).innerhtml
    $comment3 = $oDivs(8).innerhtml
    _ArrayAdd($aTbodys,  $date & "|" &  $name & "|" &  $surname & "|" &  $title & "|" & $comment1 & "|" & $comment2 & "|" & $comment3)
next
_ArrayDisplay($aTbodys)

 

Posted

when I am in loop of collection elements, how to get current element index without using "helping variable" ($counter) ?

$oDivs = _IETagnameGetCollection($oIE, "div")
$counter = 0
For $oDiv in $oDivs
    ConsoleWrite("Div index " & $counter & "/" & $oDivs.length & @CRLF)
    $counter += 1
Next

 

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
  • Recently Browsing   0 members

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