I'm attempting to scrape this webpage 10 Fast Fingers and want to pull the words you're supposed to type into a list so that I can then type them out into the text box below.
The code runs, but after the visibly loaded words, it only loads in empty strings instead of the nearly 300 words I was expecting.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
import time
driver = webdriver.Chrome()
driver.get("https://10fastfingers.com/typing-test/english")
driver.find_element(By.ID, "CybotCookiebotDialogBodyButtonDecline").click()
word_list = []
words = driver.find_elements(By.CSS_SELECTOR, "#row1>span[wordnr]")
for word in words:
word_list.append(word.text)
print(word_list)
This is what I have so far, I'm used to python but not HTML/CSS so I'm having a bit of trouble finding the right elements.
The output looks like this everytime (with the visible words being different each load)
['mother', 'white', 'might', 'sound', 'us', "it's", 'man', 'home', 'under', 'on', 'tell', 'kind', 'seem', 'the', 'can', 'after', 'just', 'stop', 'on', 'Indian', 'some', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']
Ok well I figured out the problem incase anyone else is having the same issue. The .text call on each element only grabs visible text, so instead I used .get_attribute("textContent") and that worked.