Answer a question

I am trying to get to the texts inside the span tags by iterating through the li list of this HTML:

<ol class="KambiBC-event-result__score-list">
    <li class="KambiBC-event-result__match">
        <span class="KambiBC-event-result__points">1</span>
        <span class="KambiBC-event-result__points">1</span>
    </li>
</ol>

but i am getting the error

AttributeError: 'list' object has no attribute 'find_element_by_class_name'

on my code:

meci = driver.find_elements_by_class_name('KambiBC-event-result__match')

for items in meci:

 scor = meci.find_element_by_class_name('KambiBC-event-result__points')


 print (scor.text)

Answers

You are not using items inside the loop. You loop should be

meci = driver.find_elements_by_class_name('KambiBC-event-result__match')

for items in meci:
    scor = items.find_element_by_class_name('KambiBC-event-result__points')
    print (scor.text)

meci.find_element_by_class_name should be items.find_element_by_class_name

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐