Jump to content

another way to find inner text from div class ?

Recommended Posts

here is the snippet I found in forums and using 

$tags = $oIE.document.GetElementsByTagName("div")
    For $tag In $tags
        $class_value = $tag.GetAttribute("class")
        If $class_value = "data" Then
             $season_no = $tag.innerText

 to get episode no the problem there is that there are two div tag with same class name and id and the value i want is in second one but the snippet returns only first value so any way to get the second value ?

<div class="row"><div class="field">Views: </div> <div class="value">640318</div></div>

<div class="row"><div class="field">Episodes: </div> <div class="value">11</div></div>

here is the page url http://o2tvseries.com/Agents-of-SHIELD/Season-03/index.html

EDIT1:Error resolved

EDIT2:Space problem resolved ( there was a single space there added but the console log showed a big one so i panicked )

Edited by zreo15
i reosolved the error but the unexpected space still remains
Link to post
Share on other sites

Your script have an "Exitloop" which means it should stop after the first match, Use this instead:

#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

Local $oIE = _IECreate("http://o2tvseries.com/Agents-of-SHIELD/Season-03/index.html")
Local $oTags = _IETagNameGetCollection($oIE, "div")
Local $aResults[1]
For $oTag In $oTags
    if $oTag.GetAttribute("class") == "data" Then
        _ArrayAdd($aResults, $oTag.innerTEXT)
$aResults[0] = UBound($aResults) - 1

_ArrayDisplay($aResults, "Episodelist")



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

    No registered users viewing this page.

  • Create New...