Issue
I want to scrape Home team and Away team from this page https://www.flashscore.com/match/hY5c1Bhh/#match-summary/match-summary
# Get HomeTeam
_ht = driver.find_element_by_xpath('//*[contains(@class, "home")]')
ht = _ht.find_element_by_xpath('//*[contains(@class, "participantName")]')
_homeName = ht.text
# Get AwayTeam
_at = driver.find_element_by_xpath('//*[contains(@class, "away")]')
at = _at.find_element_by_xpath('//*[contains(@class, "participantName")]')
_awayName = at.text
Output
Longford
Longford
Solution
try to store both of them in a list like this :
teams = driver.find_elements(By.CSS_SELECTOR, "div[class^='participantName'] a")
print("Home team : ", teams[0].text)
print("Away team : ", teams[1].text)
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.