1

enter code hereI am doing web scraping to a movie page but it does not find the span although in the xpath it is fine and it recognizes it, it does not find the text, when I print it, it prints empty.

This is the code enter image description here

Evidence finding the item enter image description here

Url

https://www.cinecolombia.com/cali/peliculas/el-olvido-que-seremos xpath

//section@class="collapsible show-times-collapse"//div@class="show-times-group"//div[@class="show-times-group__attrs"]/span1

the element at the end is with brackets, I don't recognize it stack span

xpath enter image description here

And also try what was recommended to me in the answers and it doesn't work either enter image description here

1 Answer 1

2

Try this XPath:

(//div[@class='show-times-group__attrs']/span)[1]

UPD
That element is initially hidden inside collapsible element.
So, to see it with Selenium you first have to open it.
The code to get the text will be:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 20)

wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.show-times-collapse__header"))).click()

your_text = wait.until(EC.visibility_of_element_located((By.XPATH, "(//div[@class='show-times-group__attrs']/span)[1]"))).text
Sign up to request clarification or add additional context in comments.

4 Comments

still does not take the text of the span
what command do you use? Maybe you are missing a delay before it?
How am I running it in jupyter in cell 3 opens the browser and leaves it there open so that I can still do tests, with the browser open.
Can you show me how you do it from the code to get the text from the span?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.