Y
Y
yk_vova2020-09-18 17:14:01
Python
yk_vova, 2020-09-18 17:14:01

How to parse class value using Selenium?

Here is my code:

browser = webdriver.Chrome()
    browser.get('https://vip.gdz.ru/class-8/russkii_yazik/bistrova-voiteleva/1-1-prt-2/')
    btn = browser.find_element_by_xpath('/html/body/div/div[2]/main/figure/div[1]/div/img')

I need to parse the value of the src variable:
<div class="task-img-container">
    <div class="with-overtask">
        <img src="//vip.gdz.ru/attachments/images/tasks/000/057/985/0002/5a74a5083bb61.jpg" alt="ГДЗ по русскому языку 8 класс Быстрова   часть 1 / упражнение - 2, Решебник" title="">
        <div class="overtask"></div>
    </div>
</div>
                                                              
                      
<div class="task-img-container">
    <div class="with-overtask">
        <img src="//vip.gdz.ru/attachments/images/tasks/000/057/985/0002/5a74a5083beee.jpg" alt="ГДЗ по русскому языку 8 класс Быстрова   часть 1 / упражнение - 2, Решебник" title="">
        <div class="overtask"></div>
    </div>
</div>

How to do it (using Selenium)? I have some items printed:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kirillinyakin, 2020-09-18
@yk_vova

val = btn.get_attribute("src")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question