Jump to content

IE and span problem


Recommended Posts

I want to get a specific name - "word" - within certain classes in a web page. The span name with the "*******" beside it is what I'm trying to capture; the "BetterLevel2" which is always the 5 span into the TD (The stars aren't actually in the web page). There are a bunch of these on the page and that span name, the one before and after it varies from td to td.

So how do I extract the name in that span? ....if I haven't been clear let me know.

<td class="Division">
                <a href="Division.html" class="DivisionLink">
                    <span class="DivisionSection">  
                        <span class="Area">
                            <span class="Land4s">
                                <span class="BetterLevel2">*******
                                    <span class="Level4">
                                        4.6     
                                    </span>
                                </span>
                            </span>
                        </span>
                    </span>
                </a>
            </td>
Link to comment
Share on other sites

Nothing in what you pasted has a "name". The elements have a "class" (which is actually a property called .className) so there is confusion here. I don't know what you are referring to as "word". What are you trying to retrieve?

Dale

p.s. your solution will probably involve _IETagNameGetCollection or _IETableWriteToArray

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

Yes class name is what I'm trying to retrieve...the 4th one in in each td. I've been fiddling around with _IETagNameGetCollection and _IETableWriteToArray for a while before making the post, but kept coming up with nothing.

EDIT:

To be clear, I get the text that is visible on the web page and not the classname.

Edited by Champak
Link to comment
Share on other sites

OK I partially figured out what I need, I got the class names in the span tags using

$oElements = _IETagNameGetCollection ($oIE, "span")
For $oElement In $oElements
    ConsoleWrite( "Name: " & $oElement.className & @CR)
Next

This gives me ALL of the span tags. Generally it would be easy to parse this if what I was looking for was the same name or in a precise spot that I can count from the beginning. But the only way I can get the exact classNames that I want is to figure out how to get the 3rd tag within the specific tag/className "DivisionSection", or the 4th className within the td name "Division". How do I do this?

Link to comment
Share on other sites

Study this:

$oElements = _IETagNameGetCollection ($oIE, "span")
For $oElement In $oElements
    ConsoleWrite( "Name: " & $oElement.className & @CR)
    If String($oElement.className) = "DivisionSection" Then
        $oBingo = _IETagnameGetCollection($oElement, "span", 2) ; get 3rd nested span
        ConsoleWrite("Here it is: " & $oBingo.classname & @CR)
    EndIf
Next

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

Damn it, you beat me back:). The following is what I came up with, but I'm definitely going to use yours instead, MUCH neater. Thanks for your help.

$oTDSearch0 = _IETagNameGetCollection($oIE, "TD")
$i = 0
For $oTDSearch1 In $oTDSearch0
    $i += 1
    If $oTDSearch1.className = "Division"  Then
        $oSpanSearch0 = _IETagNameGetCollection($oIE, "TD", $i - 1)
        $oSpanSearch0 = _IETagNameGetCollection($oSpanSearch0, "SPAN")
        $j = 0
        For $oSpanFind In $oSpanSearch0
            $j += 1
            ConsoleWrite("!====Tagname: " & $oSpanFind.tagname & " AND " & "Name: " & $oSpanFind.className & @CR)
            If $j = 4 Then ConsoleWrite("+TARGET=================================" & $oSpanFind.className & @CRLF & @CRLF);MsgBox(0,0,$oElementa.className)
        Next
    EndIf
Next
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...