skip to Main Content

It is a dynamic span. I want to get the number that keeps changing. In this case it would be 436

Code trials:

valorliquido = navegador.find_element_by_css_selector("span[class="woocommerce-summary__item-value"]")

Got:

valorliquido = navegador.find_element_by_css_selector("span[class="woocommerce-summary__item-value"]")
                                                                   ^
SyntaxError: invalid syntax

Snapshot of the HTML:

enter image description here

2

Answers


  1. You have to take care of a couple of things:


    Solution

    Youe effective line of code will be:

    valorliquido = navegador.find_element(By.CSS_SELECTOR, "span.woocommerce-summary__item-value span[data-wp-component='Text']")
    

    To print the text 436:

    print(navegador.find_element(By.CSS_SELECTOR, "span.woocommerce-summary__item-value span[data-wp-component='Text']").text)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search