The HTML text:
<div data-v-4b11382c="" xpath="1">0,00</div>
Things that doesnt work:
timer_t = browser.find_element(By.XPATH,"(//div[@class='text-2xl font-bold font-numeric'])[1]").text
timer_t = browser.find_element(By.CSS_SELECTOR,".text-2xl.font-bold.font-numeric").text
Website with the element "https://csgoempire.com/" Its the Countdown
CodePudding user response:
You have to use explicit wait
driver.get("https://csgoempire.com/")
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR,".text-2xl.font-bold.font-numeric")))
timer_t = driver.find_element(By.CSS_SELECTOR,".text-2xl.font-bold.font-numeric").text
print(timer_t)
Output:
10.31
Process finished with exit code 0
But please understand that the text you are trying to extract is ever-changing and the frequency of change seems to be in milli-seconds, which makes it harder to grab the right value. The value that is grabbed is what the driver could capture at that moment in time.
