Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97802

Why I get only first element?

$
0
0

I'm parsing this page

I pull out links from the number2 classes. Further in the loop I go through each element of number2 and try to get the results from the class 'center bold table-odds'. To do this, I try to find the parents of each link, but the problem is that every time I get the result from the first element (in this example it is 31:25)

<table class="table-main odds prediction-table" id="prediction-table-1">
    <tbody>

        <tr class="odd">
            <td rowspan="3" class="center status-text-won">W</td>
            <td rowspan="3" id="status-IwnElQet" class="table-time center datet t1570978800-6-1-0-0 ">Today<br>15:00</td>
            <td rowspan="3" colspan="1" class="table-participant">
                <a class="number2" href="/handball/europe/challenge-cup/vogosca-sviesa-IwnElQet/#1X2;2">1X2</a>
            </td>
            <td rowspan="3" class="center bold table-odds">31:25</td>
            <td class="center table-odds result-ok"><a href="">1.50</a></td>
        </tr>

        <tr class="even">
            <td rowspan="3" class="center status-text-lost">L</td>
            <td rowspan="3" id="status-0IZCD4u8" class="table-time center datet t1570978800-6-1-0-0 ">Today<br>15:00</td>
            <td rowspan="3" colspan="2" class="table-participant">
                <a class="number2" href="/volleyball/italy/serie-a2-women/marignano-talmassons-0IZCD4u8/#ah;2;-14.50;3">AH -14.5 Points</a>
            </td>
            <td rowspan="3" class="center bold table-odds">3:1</td>
            <td class="center table-odds result-ok"><a href="">2.01</a></td>
        </tr>

    </tbody>
</table>
odds = driver.find_elements_by_class_name('number2')

for odd in odds:   
     print(odd.get_attribute('href')) 
     print(odd.find_element_by_xpath('../..').find_element_by_class_name('center bold table-odds').text)

Viewing all articles
Browse latest Browse all 97802

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>