Wie bekomme ich Text eines Div -Elements mit Selen in Python?Python

Python-Programme
Anonymous
 Wie bekomme ich Text eines Div -Elements mit Selen in Python?

Post by Anonymous »

Ich versuche immer wieder, den Text dieses Divs zu finden, und es kommt immer wieder auf:

Code: Select all

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".match-team__score match__score--home u-font-weight-300"}< /code> < /p>

 Sehr neu im Web -Scraping.scorehome = match.find_element(By.CLASS_NAME, "match-team__score match__score--home u-font-weight-300")
match_scorehome = scorehome.get_attribute("outerHTML")
print(match_scorehome)
scoreaway = match.find_element(By.CLASS_NAME, "match-team__score match__score--away u-font-weight-300")
match_scoreaway = scoreaway.get_attribute("outerHTML")
print(match_scoreaway)
< /code>
Ich habe auch versucht, nach XPath zu suchen. Das gleiche Ergebnis 'Nein eines solchen Elements' < /p>
Als Referenz hier ist der Code der Website, den ich versuche, den Text aus zu erhalten: < /p>

Scored
6
points

< /code>
Das erwartete Ergebnis sollte '6' keiner des Textes aus den Spans sein.match_scorehome = wait.until(EC.visibility_of_element_located((By.XPATH, "//div[contains(@class, 'match-team__score match__score--away u-font-weight-300')]"))).text                     print(match_scorehome)
< /code>
Wenn dies überhaupt hilft, ist hier der andere zugehörige Code: < /p>
wait = WebDriverWait(driver, 30)
match_elements = wait.until(EC.presence_of_all_elements_located((By.ID, "draw-content")))
Es geht in eine für Schleife (für Match in Match_elements) und funktioniert für jedes andere Element (Teamnamen und Datum).

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post